Collage

n. A piece of art made by sticking various different materials, aka PHENOMENA Magazine
Department
programming

programming

How to disable direct access to a web site by ip address
Neither of above helped in my case - IP connection to http works as expected but https was redirecting to alphabetically first https virtual site. What was working witn nginx below 1.19.4 was to add null certificate to block: server { listen 80 default_server; listen [::]:80 default_server; listen 443 default_server; listen [::]:443 default_server; ssl_certificate /etc/ssl/null.crt; ssl_certificate_key /etc/ssl/null.key; server_name ""; return 444; }   Certificte can be generated with empty CN so you need no worry about fill it. sudo openssl req -x509 -newkey rsa:2048 -days 10000 -nodes -subj "/C=US/ST=Florida/L=XXXXX/O=Foo Inc./OU=IT/CN=X" -keyout null.key -out null.crt   Then http/https returns 444 (ERR_EMPTY_RESPONSE), in different configurations https returns ERR_HTTP2_PROTOCOL_ERROR with your null certificate which is also fine to show there is nothing there. For nginx 1.19.4 it is simpler. It introduced ssl_reject_handshake on | off (http://nginx.org/en/docs/http/ngx_http_ssl_module.html#ssl_reject_handshake) you can replace certificates 'stuff' with: server { listen 80 default_server; listen [::]:80 default_server; listen 443 default_server; listen [::]:443 default_server; ssl_reject_handshake on; server_name ""; return 444; }   And now you get http 444 (ERR_EMPTY_RESPONSE) and for https ERR_SSL_UNRECOGNIZED_NAME_ALERT. No null certificates are needed.   Ref. how to disable direct access to a web site by ip address I have a website on a VPS. The issue I am having is that when I enter the IP of the server, it links to the website. Even when entering mail.domain.com, it does the same thing. How do I disable t... https://stackoverflow.com/questions/29104943/how-to-disable-direct-access-to-a-web-site-by-ip-address OpenSSL: A problem with Field Name abbreviations? I am trying to create a new private key and CSR file for a colleague with some provided details: C = US S = Florida L = XXXXX O ... https://stackoverflow.com/questions/55541601/openssl-a-problem-with-field-name-abbreviations
server · Nov. 28, 2023, 9:14 p.m.
nginx ssl
Common SSL Issues on Python and How to Fix it
SSL certificate_verify_failed errors typically occur as a result of outdated Python default certificates or invalid root certificates. When client receives the server’s certificate, it begins chaining that certificate back to its root. It will begin by following the chain to the intermediate that has been installed, from there it continues tracing backwards until it arrives at a trusted root certificate. If the certificate is valid and can be chained back to a trusted root, it will be trusted. If it can’t be chained back to a trusted root, the browser will issue a warning about the certificate.   Common issues :  CERTIFICATE_VERIFY_FAILED [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate. HTTPSConnectionPool(host='oriel.com' , port=443): Max retries exceeded with url: / (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)')))   How to fix it :  We will have several ways to fix this issue in this article.  We will skip the SS certificate check in the first three solutions.  For the fourth solution, we are going to install the latest CA certificate from certifi. Common Quick Fixes for All OS : import ssl import certifi from urllib.request import urlopen request = "https://nd-123-456-789.p2pify.com/901c7d18b72538fd3324248e1234" urlopen(request, context=ssl.create_default_context(cafile=certifi.where()))   Or we can try it in several ways as per in below articles 1. Create unverified context in SSL import ssl context = ssl._create_unverified_context() urllib.request.urlopen(req,context=context)   2. Create unverified https context in SSL import ssl ssl._create_default_https_context = ssl._create_unverified_context urllib2.urlopen(“https://google.com”).read()   3. Use requests module and set ssl verify to false requests.get(url, headers=Hostreferer,verify=False) * It's not recommended to use verify=False in your organization's environments. This is essentially disabling SSL verification. Sometimes, when you are behind a company proxy, it replaces the certificate chain with the ones of Proxy. Adding the certificates in cacert.pem used by certifi should solve the issue. I had similar issue. Here is what I did, to resolve the issue - Find the path where cacert.pem is located - Install certifi, if you don't have. Command: pip install certifi import certifi certifi.where() C:\\Users\\[UserID]\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\site-packages\\certifi\\cacert.pem Open the URL on a browser. Download the chain of certificates from the URL and save as Base64 encoded .cer files. Now open the cacert.pem in a notepad and just add every downloaded certificate contents (---Begin Certificate--- *** ---End Certificate---) at the end.   4. Update SSL certificate with PIP It is likely that the SSL certificate issued by the server is not trusted on your client. To fix this, you can either use a trusted certificate from a recognized certificate authority on the API end, or add the certificate authority from your API to your client. if the error stay, try these commands to update your SSL certificate libs With PIP. All we would have to do is to update our SSL certificate directory with the following piece of code: if older version of python3 pip install –upgrade certifi if newer version of python3 python -m pip install --upgrade certifi What this command does is update our system’s SSL certificate directory. This will ensure that your client has the latest version of the library, which includes a set of trusted root certificates that may be needed to verify SSL certificates.   5. Update SSL certificate with certifi (MacOS only) All we would have to do is to run command with the following piece of code: - Press "command + space" button or open Spotlight - type "Install Certificates.command" What this command does is update our system’s SSL certificate directory for MacOS.   https://support.chainstack.com/hc/en-us/articles/9117198436249-Common-SSL-Issues-on-Python-and-How-to-Fix-it Unable to get local issuer certificate when using requests here is my code import requests; url='that website'; headers={ 'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8', 'Accept-Language':'zh-CN,zh;q=0.... https://stackoverflow.com/questions/51925384/unable-to-get-local-issuer-certificate-when-using-requests HTTPSConnectionPool: Max retries exceeded with URL (Caused by SSLError) I am trying to make an HTTPS request to a URL using Python requests library and certifi library as follows: import certifi url = 'https://10.0.0.39:4455/api/cars' response = requests.get(url, verify= https://stackoverflow.com/questions/75913891/httpsconnectionpool-max-retries-exceeded-with-url-caused-by-sslerror CERTIFICATE_VERIFY_FAILED error Python Django error: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1131)> Exception Location: /usr/lib/python3.8/u... https://askubuntu.com/questions/1401379/certificate-verify-failed-error Why do I receive 'unable to get local issuer certificate (_ssl.c:997)' When sending a request to a specific URL I get an SSL error and I am not sure why. First please see the error message I am presented with: requests.exceptions.SSLError: HTTPSConnectionPool(host='di... https://stackoverflow.com/questions/70977935/why-do-i-receive-unable-to-get-local-issuer-certificate-ssl-c997 SSLError: max retries exceeded with url error? How to fix this? I am attempting to scrape text off of websites, and I am using the requests module to do so. With the given code (Facebook as an example here) requests.get('http://facebook.com') I receive back the https://stackoverflow.com/questions/72188582/sslerror-max-retries-exceeded-with-url-error-how-to-fix-this
python · Aug. 29, 2023, 8:15 p.m.
ssl python
How to easily convert utf8 tables to utf8mb4 in MySQL 5.5
From my guide How to support full Unicode in MySQL databases, here are the queries you can run to update the charset and collation of a database, a table, or a column:   For each database: ALTER DATABASE database_name CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;   For each table: ALTER TABLE table_name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;   For each column: ALTER TABLE table_name CHANGE column_name column_name VARCHAR(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;   (Don’t blindly copy-paste this! The exact statement depends on the column type, maximum length, and other properties. The above line is just an example for a VARCHAR column.) Note, however, that you cannot fully automate the conversion from utf8 to utf8mb4. As described in step 4 of the abovementioned guide, you’ll need to check the maximum length of columns and index keys, as the number you specify has a different meaning when utf8mb4 is used instead of utf8. Section 10.1.11 of the MySQL 5.5 Reference Manual has some more information on this.   How to easily convert utf8 tables to utf8mb4 in MySQL 5.5 I have a database which now needs to support 4 byte characters (Chinese). Luckily I already have MySQL 5.5 in production. So I would just like to make all collations which are utf8_bin to utf8mb4_... https://dba.stackexchange.com/questions/8239/how-to-easily-convert-utf8-tables-to-utf8mb4-in-mysql-5-5
server · Aug. 6, 2023, 8:52 a.m.
Path with “WEB-INF” or “META-INF”
The spring boot error Path with “WEB-INF” or “META-INF” occurs when the jsp page url is invoked and the tomcat jasper dependency is not configured in the application. The jsp files are compiled and rendered using the tomcat embedded jasper maven dependency. If the maven dependency is not configured in the spring boot application, the “path with WEB-INF or META-INF” error will be shown in the console. In the spring boot application, when you access a jsp page in browser, it shows “Whitelabel Error Page, There was an unexpected error (type=Not Found, status=404).” error in the browser. The exception to this is “HTTP 404 – page not found”. In the spring boot console log, the error is shown as ‘Path with ‘WEB-INF’ or ‘META-INF’. The ResourceHttpRequestHandler class will throw the error as “o.s.w.s.r.ResourceHttpRequestHandler : Path with “WEB-INF” or “META-INF”:”   Exception The exception stack trace will be shown below. This will be displayed in the console when a jsp page is invoked. 2019-10-03 13:17:57.140 WARN 3200 --- [nio-8080-exec-1] o.s.w.s.r.ResourceHttpRequestHandler : Path with "WEB-INF" or "META-INF": [WEB-INF/jsp/helloworld.jsp] 2019-10-03 13:17:57.154 WARN 3200 --- [nio-8080-exec-1] o.s.w.s.r.ResourceHttpRequestHandler : Path with "WEB-INF" or "META-INF": [WEB-INF/jsp/error.jsp]   How to reproduce this issue This error can be replicated in the mvc spring boot application. Follow the steps below to reproduce this issue. Create a spring boot mvc project in the Spring Tool Suite editor. Set up the jsp folder in the application.properties file as shown below. application.properties spring.mvc.view.prefix:/WEB-INF/jsp/ spring.mvc.view.suffix:.jsp Create a rest controller class to configure and invoke a url that will map to jsp file. Create a method in the controller class and configure the request mapping url to invoke. Configure a jsp file in the method that will be rendered when the url is invoked. HelloWorldController.java package com.yawintutor; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.servlet.ModelAndView; @Controller public class HelloWorldController { @RequestMapping("/HelloWorld") public ModelAndView firstPage() { return new ModelAndView("helloworld"); } } Create a jsp file that is configured in the controller class. In this example, a helloworld.jsp file is created in the src / main / webapp / WEB-INF / jsp / folder. The jsp file contains a simple message. src/main/webapp/WEB-INF/jsp/helloworld .jsp <h1>Welcome to Hello World!</h1> Open a browser and call the url as “http://localhost:8080/HelloWorld”. This url should invoke firstPage method in HelloWorldController class. The model view is configured with helloworld. the file in src/main/webapp/WEB-INF/jsp/helloworld.jsp should be rendered.   Root Cause The jsp path resolving class is available in tomcat jasper package. The dependency of tomcat jasper is not added in pom.xml. So the jsp path is not resolved by spring boot application   Solution The dependent jars are available in tomcat jasper. Add tomcat jasper dependency in pom.xml file <dependency> <groupId>org.apache.tomcat.embed</groupId> <artifactId>tomcat-embed-jasper</artifactId> </dependency>   Ref. Path with “WEB-INF” or “META-INF” – Yawin Tutor Skip to content Home Java C Spring Boot Issues Spring Boot Python Database Others Technicals Contact Us Home Java C Spring Boot Issues Spring Boot Python Database Others Technicals Contact Us Path with “WEB-INF” or “META-INF” The spring boot error Path wi https://www.yawintutor.com/warn-3200-path-with-web-inf-or-meta-inf/  
java · Aug. 3, 2023, 9:02 a.m.
java spring
ㅋㅋㅋ답변이 재밌네.
ASP.net c# - Could not load type - Stack Overflow   ASP.net c# - Could not load type On my page I have: <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="siteSettings.aspx.cs" Inherits="APack.admin.siteSettings" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 https://stackoverflow.com/questions/3447762/asp-net-c-sharp-could-not-load-type   대박🤣🤣🤣
C · June 27, 2023, 10:44 a.m.
Troubleshooting for Django
1) 장고 패스워드 재설정 시 이메일이 안보내지는 경우 패스워드 리셋 이메일은 active user(is_active가 true) 이면서 사용가능한 패스워드가 설정되어 있는 유저인 경우(has_usable_password 도 true) 에만 전송이 된다. 즉 gmail이나 네이버 oauth 등으로 가입한 유저의 경우에는 패스워드를 직접 타이핑하여 설정한 경우가 아니기에 패스워드 리셋 이메일이 안 보내지는 것이다. 아무 오류도 안뜨고 마치 전송된 것처럼 나올 수 있으므로 주의. Django: reset-password not sending email I am using the Django password reset. I have this code in my settings.py: EMAIL_USE_TLS = True EMAIL_HOST = 'smtp.gmail.com' EMAIL_PORT = 587 EMAIL_HOST_USER = 'myusername@gmail.com' https://stackoverflow.com/questions/20325729/django-reset-password-not-sending-email   2) 장고 특정 app에 다국어 추가 1. 해당 app에 locale 폴더를 만든다. 2. 가상경로에서 해당 app 경로로 이동 3. 다음 명령을 실행 django-admin makemessages -l ja 4. 컴파일 django-admin compilemessages How do I run makemessages so it includes some apps that are outside the Django project? I have the following structure: . ├── apps │   ├── app1 │ │ ├── app1 │ │ └── setup.py │   ├── app2 │ │ ├── app2 │ │ └── setup.py ├── my_django_project │   ├── appA │   ├── appB │  ... https://stackoverflow.com/questions/30426823/how-do-i-run-makemessages-so-it-includes-some-apps-that-are-outside-the-django-p   3) requirements.txt 를 통한 패키지 종속성 관리 현재 환경에서 설치한 패키지 확인 pip freeze 설치한 패키지 목록을 파일에 담기 pip freeze > requirements.txt 패키지 설치 pip install -r requirements.txt ssl 오류가 발생할 경우에는 pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org -r requirements.txt   4) django management 시스템 안에서 내 명령어 만들고 사용하기 app들을 import하여 만든 코드를 서버시작없이 콘솔에서 테스트 또는 실행하고 싶을 때 유용함. 그냥 Run 해버리면 import된 모듈을 찾을 수 없다고 나온다. shell 명령을 쓰지않아도 되어서 편하다 1. 폴더구조를 아래와같이 만들어야 한다 $ tree CallCenter ├── admin.py ├── apps.py ├── __init__.py ├── management │ └── commands 2. 이제 commands 폴더 안에 내가 쓰고자 하는 명령어의 이름으로 python 파일을 작정한다 여기서는 make_call.py CallCenter/management/commands/make_call.py from twilio.rest import Client from twilio.twiml.voice_response import VoiceResponse, Say, Dial, Number, VoiceResponse from CallCenter.models import Campaign from django.core.management import BaseCommand def create_xml(campaign): # Creates XML response = VoiceResponse() response.say(campaign.campaign_text) return response class Command(BaseCommand): def add_arguments(self, parser): parser.add_argument("--campaign-id", required=True, type=int) def handle(self, campaign_id, **options): campaign = Campaign.objects.get(pk=campaign_id) xml = create_xml(campaign) print(xml) 3. 아래와 같이 실행하면 된다 $ python manage.py make_call --campaign-id=1 How to run a python script in Django? I am new to Django, and I'm trying to import one of my models in a script as we do it in views.py. I'm getting an error: Traceback (most recent call last): File "CallCenter\make_call.py", line ... https://stackoverflow.com/questions/58286858/how-to-run-a-python-script-in-django   5) django를 이용한 소셜 로그인 소셜로그인의 양대산맥: GitHub - pennersr/django-allauth: Integrated set of Django applications addressing authentication, registration, account management as well as 3rd party (social) account authentication. Integrated set of Django applications addressing authentication, registration, account management as well as 3rd party (social) account authentication. - GitHub - pennersr/django-allauth: Integrate... https://github.com/pennersr/django-allauth GitHub - python-social-auth/social-app-django: Python Social Auth - Application - Django Python Social Auth - Application - Django. Contribute to python-social-auth/social-app-django development by creating an account on GitHub. https://github.com/python-social-auth/social-app-django app을 등록한 후 사용하면 된다 트위터: Twitter Developers   JavaScript is not available. We’ve detected that JavaScript is disabled in this browser. Please enable JavaScript or switch to a supported browser to continue using twitter.com. You can see a list of supported browsers in our Help Center. Help Center Term https://developer.twitter.com/en/portal/petition/essential/basic-info 네이버: 애플리케이션 - NAVER Developers 애플리케이션 - NAVER Developers   https://developers.naver.com/apps/#/list 네이버로 연동된 app목록은 여기서 확인가능 Apps : NAVER Account 네이버 네이버에 로그인 하고 나를 위한 다양한 서비스를 이용해 보세요 https://nid.naver.com/internalToken/view/tokenList/pc/en 구글: https://console.developers.google.com/apis/dashboard Google Cloud Platform Sign into continue to Google Cloud PlatformEmail or phoneForgot email?Type the text you hear or seeNot your computer? Use Guest mode to sign in privately. Learn moreNextCreate account https://console.developers.google.com/apis/dashboard 이중 가장 까다로웠던건 네이버연동. 첨에 신청했다가 어떤목적 사이트인지 기술안했다고 반려당하고 가입시 선택사항으로 이름을 넣어놨는데 사용목적이 안나왔다고 반려당하고 선택사항삭제하고 별명을 필수로 넣었는데 어디에 쓰이는지 알수없다고해서 캡쳐후 재신청하고 검수 승인까지 좀 걸렸었다.
python · June 27, 2023, 10:27 a.m.
django
recv() failed (104: Connection reset by peer) while reading response header from upstream
LinkedIn sharing has not worked for me. So I checked a URL from LinkedIn’s Post Inspector.     A 400 error has occurred. I checked the server error log again. [error] 4993#4993: *22595 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 1.1.1.1, server: example.com, request: "GET / HTTP/1.1", upstream: "uwsgi://unix://www/webservice.sock:", host: "example.com", referrer: "url" This snippet is for future me. Most answers for this problem you'll see are related to PHP. This issue is related to the buffer size in the uWSGI. Probably your requests have a long query parameters and cookies.   First, I added the following code to nginx.conf: reset_timedout_connection on; keepalive_requests 1000; send_timeout 30; server_names_hash_max_size 2048; #access_log /var/log/nginx/access.log; access_log off; log_not_found off; but it still has not worked.   One setting that occasionally needs to be adjusted is UWSGI_BUFFER_SIZE. The default value is 4096. If you plan to receive relatively big requests, you'll need to change this parameter value. You can tune it up to 65535. I do it in my application config uwsgi ini file. ( basically ini file is in /etc/uwsgi/ ) buffer-size=32768   * If you want to show an OG image, then you have to resize the image to 1200 px, etc. My image was 4032x3024, and it didn't show up.   Now everything works fine. :)   Ref. uWSGI. recv() failed (104: Connection reset by peer) while reading response header from upstream / abstractkitchen.com abstractkitchen.com uWSGI. recv() failed (104: Connection reset by peer) while reading response header from upstream Posted by Dmitry Updated on December 04, 2022 python uwsgi error snippet nginx [error] 4993#4993: *22595 recv() failed (104: Connection re https://abstractkitchen.com/blog/recv-failed-connection-reset-by-peer/ How to manage uWSGI configuration - Divio Documentation Divio Documentation Contents Menu Expand Light mode Dark mode Auto light/dark mode Hide navigation sidebar Hide table of contents sidebar Toggle site navigation sidebar Divio Documentation Toggle Light / Dark / Auto color theme Toggle table of contents si https://docs.divio.com/en/latest/how-to/uwsgi-configuration/ https://yoast.com/help/linkedin-sharing-not-working/ uwsgi invalid request block size I am running uwsgi in emperor mode uwsgi --emperor /path/to/vassals/ --buffer-size=32768 and getting this error invalid request block size: 21327 (max 4096)...skip What to do? I also tried -b 32768. https://stackoverflow.com/questions/15878176/uwsgi-invalid-request-block-size Where do you create the ini file? (Uwsgi) my reference: https://docs.djangoproject.com/en/4.0/howto/deployment/wsgi/uwsgi/ my project name: 'mysite' my directories: I create 'uwsgi.ini'. then, I written in ini file. [uwsgi] chdir=/var/ww... https://stackoverflow.com/questions/70811918/where-do-you-create-the-ini-file-uwsgi  
server · June 26, 2023, 3:45 a.m.
python uwsgi nginx
How To Secure Nginx with Let's Encrypt on Ubuntu
Step 1. Installing Certbot # apt-get install letsencrypt or # apt-get install certbot   Step 2. Confirming Nginx’s Configuration To check, open the server block file for your domain using nano or your favorite text editor: # sudo nano /etc/nginx/sites-available/your_domain Find the existing server_name line. It should look like the following: ... server_name your_domain www.your_domain; ... If it does, exit your editor and move on to the next step.   Step 3. Obtaining an SSL Certificate # letsencrypt certonly --webroot --webroot-path=/home/myuser3/www -d your_domain.com -d www.your_domain.com * How to Solve Error 404 Not Found & How to Fix it Failed authorization procedure. your_domain.com (http-01): urn:ietf:params:acme:error:unauthorized :: The client lacks sufficient authorization :: 160.153.63.10: Invalid response from https://www.your_domain.com/.well-known/acme-challenge/ABCDE12345: 404, www.your_domain.com (http-01): urn:ietf:params:acme:error:unauthorized :: The client lacks sufficient authorization :: 160.153.63.10: Invalid response from https://www.your_domain.com/.well-known/acme-challenge/VWXYZ67890: 404 IMPORTANT NOTES: - The following errors were reported by the server: Domain: your_domain.com Type: unauthorized Detail: 160.153.63.10: Invalid response from https://www.your_domain.com/.well-known/acme-challenge/ABCDE12345: 404 Domain: www.your_domain.com Type: unauthorized Detail: 160.153.63.10: Invalid response from https://www.your_domain.com/.well-known/acme-challenge/VWXYZ67890: 404 To fix these errors, please make sure that your domain name was entered correctly and the DNS A/AAAA record(s) for that domain contain(s) the right IP address. Edit Nginx’s Configuration location /.well-known { alias /root/folder/$site_name/.well-known/$1; } * If successful, you will receive the following output: Saving debug log to /var/log/letsencrypt/letsencrypt.log Plugins selected: Authenticator webroot, Installer None Obtaining a new certificate Performing the following challenges: http-01 challenge for your_domain.com http-01 challenge for www.your_domain.com Using the webroot path /root/folder/your_domain for all unmatched domains. Waiting for verification... Cleaning up challenges Running deploy-hook command: systemctl reload nginx IMPORTANT NOTES: - Congratulations! Your certificate and chain have been saved at: /etc/letsencrypt/live/your_domain/fullchain.pem Your key file has been saved at: /etc/letsencrypt/live/your_domain/privkey.pem Your cert will expire on 2023-09-18. To obtain a new or tweaked version of this certificate in the future, simply run certbot again. To non-interactively renew *all* of your certificates, run "certbot renew" - If you like Certbot, please consider supporting our work by: Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate Donating to EFF: https://eff.org/donate-le   Step 4. Edit Nginx’s Configuration Add this block: #ssl beginning ssl on; ssl_certificate /etc/letsencrypt/live/your_domain/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/your_domain/privkey.pem; ssl_dhparam /etc/ssl/certs/dhparam.pem; #ssl end   Ref. How To Secure Nginx with Let's Encrypt on Ubuntu 18.04 | DigitalOcean New! Premium CPU-Optimized Droplets are now available. Learn more ->We're hiringBlogDocsGet SupportContact SalesProductsFeatured ProductsDropletsScalable virtual machinesKubernetesManaged Kubernetes clustersCloudwaysManaged cloud hostingApp PlatformGet ap https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-18-04 Let’s Encrypt: How to Automatically Restart Nginx With Certbot – Arnon on Technology close search homeHome chatContact Me Categories labelGenerallabelHow-To GuideslabelMetalabelNewslabelOp-EdlabelServer Logs Explained Archives folderDecember 2021 folderJune 2021 folderMarch 2021 folderJanuary 2021 folderDecember 2020 folderOctober 2020 fo https://blog.arnonerba.com/2019/01/lets-encrypt-how-to-automatically-restart-nginx-with-certbot [Ubuntu] Let’s Encrypt 를 사용하여 무료로 SSL 사이트를 구축하는 방법 웹은 계속 발전하고 있으며, 여러 새로운 기술이 끊임 없이 등장하고 있다. 이 글에서는 웹 기술 중 하나인 SSL (Secure Socket Layer) 에 대해서 이야기 해 보고자 한다. < 그림 : OSI Model 에서 SSL 의 위치 >   정확히 말해서 SSL 은 전송계층과 (Transport Layer) 응용계층 (App… https://blog.lael.be/post/5107  
server · June 22, 2023, 11:33 p.m.
nginx Let’s Encrypt
How to Draw 4-Leaf Clover Using a Turtle in Python
This graphics system is a great way for beginners to conquer both Python and 2D drawing.   Code: import turtle as t def draw_leaf(color): t.begin_fill() t.color(color) t.left(50) t.forward(60) t.circle(25, 190) t.right(100) t.circle(25, 180) t.forward(50) t.left(50) t.end_fill() def draw_stem(degree, length, color): t.rt(degree) t.pensize(5) t.color(color) t.fd(length) t.back(length) t.lt(degree) n = 4 color = 'green' t.setup(430, 430) draw_stem(90, 150, color) t.pensize(2) for i in range(n): draw_leaf(color) t.home() t.lt((360 / n) * (i + 1)) t.pu() t.mainloop()   Result:  
python · June 22, 2023, 8:29 p.m.
Turtle clover
Spring Boot @WebServlet Annotation Example
TestServlet.java package com.blood.money.test.servlet; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @WebServlet( name = "Example", description = "Example Servlet", urlPatterns = {"/Example"} ) public class TestServlet extends HttpServlet { /** * */ private static final long serialVersionUID = 1L; @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter writer = response.getWriter(); String html = "<html>"; html += "<body>"; html += "<div>THIS IS NOT A TEST</div>"; html += "</body>"; html += "</html>"; writer.println(html); } }   How do I get Spring Boot to auto-load all @WebServlet annotated servlets and honor their url mappings? Add @ServletComponentScan in your bootstrap class. such as @SpringBootApplication @ServletComponentScan public class BadApplication { public static void main(String[] args) { SpringApplication.run(BadApplication.class, args); } }  
java · June 22, 2023, 7:56 p.m.
spring Servlet
ASP.NET Error Handling
< Sample Code 1 : / > Server Error in '/' Application. Conversion from string "" to type 'Decimal' is not valid. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.InvalidCastException: Conversion from string "" to type 'Decimal' is not valid. Source Error: Line 91: city = reader_ull("City").ToString() Line 92: zip = reader_ull("Zip").ToString() Line 93: lat = reader_ull("Latitude").ToString() Line 94: lng = reader_ull("Longitude").ToString() Line 95: Source File: D:\home\site\wwwroot\include\functions.aspx    Line: 93 Stack Trace: [InvalidCastException: Conversion from string "" to type 'Decimal' is not valid.] Microsoft.VisualBasic.CompilerServices.Conversions.ToDecimal(String Value, NumberFormatInfo NumberFormat) +254 Microsoft.VisualBasic.CompilerServices.Conversions.ToDecimal(String Value) +6 ASP.default_aspx.GetLocation() in D:\home\site\wwwroot\include\functions.aspx:93 ASP.default_aspx.__Render__control1(HtmlTextWriter __w, Control parameterContainer) in D:\home\site\wwwroot\include\head1.aspx:12 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +256 System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19 System.Web.UI.Page.Render(HtmlTextWriter writer) +29 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27 System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99 System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1266 Version Information: Microsoft .NET Framework Version:2.0.50727.8964; ASP.NET Version:2.0.50727.8962   < Sample Code 2 : /include/functions.aspx > Server Error in '/' Application. Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. Compiler Error Message: BC30451: Name 'userLat' is not declared. Source Error: Line 34: If Not latCookie Is Nothing And Not lngCookie Is Nothing And Request.Querystring("nolocation") <> "nolocation" Line 35: Try Line 36: userLat = latCookie.Value Line 37: userLng = lngCookie.Value Line 38: userLocation = Request.Cookies("Location").Value.ToString().Replace("_", " ") Source File: D:\home\site\wwwroot\include\functions.aspx    Line: 36 Compiler Warning Messages: Warning: BC42104: Variable 'ipFinal' is used before it has been assigned a value. A null reference exception could result at runtime. Source Error: D:\home\site\wwwroot\include\functions.aspx Line 13: End If Line 14: Line 15: If ipFinal = Nothing Line 16: ipFinal = context.Request.ServerVariables("REMOTE_ADDR") Line 17: End If Warning: BC42024: Unused local variable: 'R'. Source Error: D:\home\site\wwwroot\include\functions.aspx Line 432: Line 433:Function stripHtml(ByVal Y As String) As String Line 434: Dim R As RegEx Line 435: Line 436: If Y = Nothing Then Return("") Warning: BC42025: Access of shared member, constant member, enum member or nested type through an instance; qualifying expression will not be evaluated. Source Error: D:\home\site\wwwroot\include\functions.aspx Line 436: If Y = Nothing Then Return("") Line 437: Line 438: Y=R.Replace(Y, "<[^>]*(>|$)", "") Line 439: Line 440: Return(Y) Warning: BC42021: Function without an 'As' clause; return type of Object assumed. Source Error: D:\home\site\wwwroot\include\functions.aspx Line 441:End Function Line 442: Line 443:Function getStateSmall(ByVal strState As String) Line 444: Select Case (strState & "").ToLower() Line 445: Case "alabama" Warning: BC42021: Function without an 'As' clause; return type of Object assumed. Source Error: D:\home\site\wwwroot\include\functions.aspx Line 578:End Function Line 579: Line 580:Function getStatePath(ByVal strState As String) Line 581: Select Case (strState & "").ToUpper() Line 582: Case "AL" Warning: BC42021: Function without an 'As' clause; return type of Object assumed. Source Error: D:\home\site\wwwroot\include\functions.aspx Line 715:End Function Line 716: Line 717:Function getStateLarge(ByVal strState As String) Line 718: Select Case (strState & "").ToUpper() Line 719: Case "AL"   Show Detailed Compiler Output: D:\Windows\system32> "D:\Windows\Microsoft.NET\Framework\v3.5\vbc.exe" /t:library /utf8output /R:"D:\Windows\assembly\GAC_MSIL\System.ServiceModel\3.0.0.0__b77a5c561934e089\System.ServiceModel.dll" /R:"D:\Windows\assembly\GAC_MSIL\System.Web.Mobile\2.0.0.0__b03f5f7f11d50a3a\System.Web.Mobile.dll" /R:"D:\Windows\assembly\GAC_MSIL\System.Web.Extensions\3.5.0.0__31bf3856ad364e35\System.Web.Extensions.dll" /R:"D:\Windows\assembly\GAC_32\System.Data\2.0.0.0__b77a5c561934e089\System.Data.dll" /R:"D:\local\Temporary ASP.NET Files\root\f32c0fa1\240b01cd\assembly\dl3\5c15a322\fc3a3152_020dd201\ICSharpCode.SharpZipLib.DLL" /R:"D:\Windows\assembly\GAC_MSIL\System.Data.DataSetExtensions\3.5.0.0__b77a5c561934e089\System.Data.DataSetExtensions.dll" /R:"D:\Windows\assembly\GAC_MSIL\System.Core\3.5.0.0__b77a5c561934e089\System.Core.dll" /R:"D:\local\Temporary ASP.NET Files\root\f32c0fa1\240b01cd\assembly\dl3\64a3753b\6fb7dd7d_0facd301\Yahoo.Yui.Compressor.DLL" /R:"D:\Windows\assembly\GAC_MSIL\System.Xml.Linq\3.5.0.0__b77a5c561934e089\System.Xml.Linq.dll" /R:"D:\Windows\assembly\GAC_MSIL\System.Drawing\2.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll" /R:"D:\local\Temporary ASP.NET Files\root\f32c0fa1\240b01cd\assembly\dl3\e3a49068\6ab1597e_0facd301\EcmaScript.NET.DLL" /R:"D:\Windows\assembly\GAC_32\System.Web\2.0.0.0__b03f5f7f11d50a3a\System.Web.dll" /R:"D:\Windows\assembly\GAC_32\System.EnterpriseServices\2.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.dll" /R:"D:\Windows\assembly\GAC_MSIL\System.Runtime.Serialization\3.0.0.0__b77a5c561934e089\System.Runtime.Serialization.dll" /R:"D:\local\Temporary ASP.NET Files\root\f32c0fa1\240b01cd\assembly\dl3\a6609ab6\d713f658_479cd301\Newtonsoft.Json.DLL" /R:"D:\Windows\assembly\GAC_MSIL\System.Web.Services\2.0.0.0__b03f5f7f11d50a3a\System.Web.Services.dll" /R:"D:\Windows\assembly\GAC_MSIL\System.ServiceModel.Web\3.5.0.0__31bf3856ad364e35\System.ServiceModel.Web.dll" /R:"D:\Windows\assembly\GAC_MSIL\System.Configuration\2.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll" /R:"D:\local\Temporary ASP.NET Files\root\f32c0fa1\240b01cd\App_global.asax.zpcwrfkc.dll" /R:"D:\Windows\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dll" /R:"D:\Windows\assembly\GAC_MSIL\System.IdentityModel\3.0.0.0__b77a5c561934e089\System.IdentityModel.dll" /R:"D:\Windows\assembly\GAC_MSIL\System.WorkflowServices\3.5.0.0__31bf3856ad364e35\System.WorkflowServices.dll" /R:"D:\Windows\assembly\GAC_MSIL\System.Web.Routing\3.5.0.0__31bf3856ad364e35\System.Web.Routing.dll" /R:"D:\Windows\assembly\GAC_MSIL\System.Xml\2.0.0.0__b77a5c561934e089\System.Xml.dll" /out:"D:\local\Temporary ASP.NET Files\root\f32c0fa1\240b01cd\App_Web_functions.aspx.c8a18792.nv4jgu4j.dll" /D:DEBUG=1 /debug+ /define:_MYTYPE=\"Web\" /imports:Microsoft.VisualBasic,System,System.Collections,System.Collections.Generic,System.Collections.Specialized,System.Configuration,System.Text,System.Text.RegularExpressions,System.Linq,System.Xml.Linq,System.Web,System.Web.Caching,System.Web.SessionState,System.Web.Security,System.Web.Profile,System.Web.UI,System.Web.UI.WebControls,System.Web.UI.WebControls.WebParts,System.Web.UI.HtmlControls /warnaserror- /optionInfer+ "D:\local\Temporary ASP.NET Files\root\f32c0fa1\240b01cd\App_Web_functions.aspx.c8a18792.nv4jgu4j.0.vb" "D:\local\Temporary ASP.NET Files\root\f32c0fa1\240b01cd\App_Web_functions.aspx.c8a18792.nv4jgu4j.1.vb" Microsoft (R) Visual Basic Compiler version 9.0.30729.8763 Copyright (c) Microsoft Corporation. All rights reserved. D:\home\site\wwwroot\include\functions.aspx(15) : warning BC42104: Variable 'ipFinal' is used before it has been assigned a value. A null reference exception could result at runtime. If ipFinal = Nothing ~~~~~~~ D:\home\site\wwwroot\include\functions.aspx(36) : error BC30451: Name 'userLat' is not declared. userLat = latCookie.Value ~~~~~~~ D:\home\site\wwwroot\include\functions.aspx(37) : error BC30451: Name 'userLng' is not declared. userLng = lngCookie.Value ~~~~~~~ D:\home\site\wwwroot\include\functions.aspx(38) : error BC30451: Name 'userLocation' is not declared. userLocation = Request.Cookies("Location").Value.ToString().Replace("_", " ") ~~~~~~~~~~~~ D:\home\site\wwwroot\include\functions.aspx(72) : error BC30002: Type 'SqlConnection' is not defined. Dim conn_ull As New SqlConnection(Application("ConnectionString")) ~~~~~~~~~~~~~ D:\home\site\wwwroot\include\functions.aspx(73) : error BC30002: Type 'SqlCommand' is not defined. Dim cmd_ull As New SqlCommand() ~~~~~~~~~~ D:\home\site\wwwroot\include\functions.aspx(84) : error BC30002: Type 'SqlDataReader' is not defined. Dim reader_ull As SqlDataReader = cmd_ull.ExecuteReader() ~~~~~~~~~~~~~ D:\home\site\wwwroot\include\functions.aspx(119) : error BC30451: Name 'userLat' is not declared. userLat = lat ~~~~~~~ D:\home\site\wwwroot\include\functions.aspx(123) : error BC30451: Name 'userLng' is not declared. userLng = lng ~~~~~~~ D:\home\site\wwwroot\include\functions.aspx(127) : error BC30451: Name 'userLocation' is not declared. userLocation = location ~~~~~~~~~~~~ D:\home\site\wwwroot\include\functions.aspx(140) : error BC30451: Name 'userLocation' is not declared. If userLocation = "" ~~~~~~~~~~~~ D:\home\site\wwwroot\include\functions.aspx(141) : error BC30451: Name 'userLocation' is not declared. userLocation = "Edit Location" ~~~~~~~~~~~~ D:\home\site\wwwroot\include\functions.aspx(143) : error BC30451: Name 'userLocation' is not declared. If userLocation.IndexOf(",") > -1 ~~~~~~~~~~~~ D:\home\site\wwwroot\include\functions.aspx(144) : error BC30451: Name 'userLocationCity' is not declared. userLocationCity = userLocation.SubString(0, userLocation.IndexOf(",")) ~~~~~~~~~~~~~~~~ D:\home\site\wwwroot\include\functions.aspx(144) : error BC30451: Name 'userLocation' is not declared. userLocationCity = userLocation.SubString(0, userLocation.IndexOf(",")) ~~~~~~~~~~~~ D:\home\site\wwwroot\include\functions.aspx(144) : error BC30451: Name 'userLocation' is not declared. userLocationCity = userLocation.SubString(0, userLocation.IndexOf(",")) ~~~~~~~~~~~~ D:\home\site\wwwroot\include\functions.aspx(145) : error BC30451: Name 'userLocationState' is not declared. userLocationState = userLocation.SubString(userLocation.IndexOf(",")) ~~~~~~~~~~~~~~~~~ D:\home\site\wwwroot\include\functions.aspx(145) : error BC30451: Name 'userLocation' is not declared. userLocationState = userLocation.SubString(userLocation.IndexOf(",")) ~~~~~~~~~~~~ D:\home\site\wwwroot\include\functions.aspx(145) : error BC30451: Name 'userLocation' is not declared. userLocationState = userLocation.SubString(userLocation.IndexOf(",")) ~~~~~~~~~~~~ D:\home\site\wwwroot\include\functions.aspx(146) : error BC30451: Name 'userLocationState' is not declared. userLocationState = userLocationState.Trim(",") ~~~~~~~~~~~~~~~~~ D:\home\site\wwwroot\include\functions.aspx(146) : error BC30451: Name 'userLocationState' is not declared. userLocationState = userLocationState.Trim(",") ~~~~~~~~~~~~~~~~~ D:\home\site\wwwroot\include\functions.aspx(147) : error BC30451: Name 'userLocationState' is not declared. userLocationState = userLocationState.Trim() ~~~~~~~~~~~~~~~~~ D:\home\site\wwwroot\include\functions.aspx(147) : error BC30451: Name 'userLocationState' is not declared. userLocationState = userLocationState.Trim() ~~~~~~~~~~~~~~~~~ D:\home\site\wwwroot\include\functions.aspx(188) : error BC30002: Type 'SqlConnection' is not defined. Dim objConn_ull As New SqlConnection(Application("ConnectionStringReadOnly")) ~~~~~~~~~~~~~ D:\home\site\wwwroot\include\functions.aspx(189) : error BC30002: Type 'SqlCommand' is not defined. Dim objCmd_ull As New SqlCommand(strSQL_ull, objConn_ull) ~~~~~~~~~~ D:\home\site\wwwroot\include\functions.aspx(193) : error BC30002: Type 'SqlDataReader' is not defined. Dim objR_ull As SqlDataReader=objCmd_ull.ExecuteReader() ~~~~~~~~~~~~~ D:\home\site\wwwroot\include\functions.aspx(391) : error BC30002: Type 'SqlConnection' is not defined. Dim objConn As New SqlConnection(Application("ConnectionString")) ~~~~~~~~~~~~~ D:\home\site\wwwroot\include\functions.aspx(392) : error BC30002: Type 'SqlCommand' is not defined. Dim objCmd As New SqlCommand(strQuery, objConn) ~~~~~~~~~~ D:\home\site\wwwroot\include\functions.aspx(408) : error BC30002: Type 'SqlConnection' is not defined. Dim objConn As New SqlConnection(Application("ConnectionString")) ~~~~~~~~~~~~~ D:\home\site\wwwroot\include\functions.aspx(409) : error BC30002: Type 'SqlCommand' is not defined. Dim objCmd As New SqlCommand(strQuery, objConn) ~~~~~~~~~~ D:\home\site\wwwroot\include\functions.aspx(434) : warning BC42024: Unused local variable: 'R'. Dim R As RegEx ~ D:\home\site\wwwroot\include\functions.aspx(438) : warning BC42025: Access of shared member, constant member, enum member or nested type through an instance; qualifying expression will not be evaluated. Y=R.Replace(Y, "<[^>]*(>|$)", "") ~~~~~~~~~ D:\home\site\wwwroot\include\functions.aspx(443) : warning BC42021: Function without an 'As' clause; return type of Object assumed. Function getStateSmall(ByVal strState As String) ~~~~~~~~~~~~~ D:\home\site\wwwroot\include\functions.aspx(580) : warning BC42021: Function without an 'As' clause; return type of Object assumed. Function getStatePath(ByVal strState As String) ~~~~~~~~~~~~ D:\home\site\wwwroot\include\functions.aspx(717) : warning BC42021: Function without an 'As' clause; return type of Object assumed. Function getStateLarge(ByVal strState As String)   Show Complete Compilation Source: Line 1: #ExternalChecksum("D:\home\site\wwwroot\include\functions.aspx","{406ea660-64cf-4c82-b6f0-42d48172a799}","3823AE249D40949B8E2B4709D23B67DB") Line 2: '------------------------------------------------------------------------------ Line 3: ' <auto-generated> Line 4: ' This code was generated by a tool. Line 5: ' Runtime Version:2.0.50727.8964 Line 6: ' Line 7: ' Changes to this file may cause incorrect behavior and will be lost if Line 8: ' the code is regenerated. Line 9: ' </auto-generated> Line 10: '------------------------------------------------------------------------------ Line 11: Line 12: Option Strict Off Line 13: Option Explicit On Line 14: Line 15: Imports Microsoft.VisualBasic Line 16: Imports System Line 17: Imports System.Collections Line 18: Imports System.Collections.Generic Line 19: Imports System.Collections.Specialized Line 20: Imports System.Configuration Line 21: Imports System.Linq Line 22: Imports System.Security.Cryptography Line 23: Imports System.Text Line 24: Imports System.Text.RegularExpressions Line 25: Imports System.Web Line 26: Imports System.Web.Caching Line 27: Imports System.Web.Profile Line 28: Imports System.Web.Security Line 29: Imports System.Web.SessionState Line 30: Imports System.Web.UI Line 31: Imports System.Web.UI.HtmlControls Line 32: Imports System.Web.UI.WebControls Line 33: Imports System.Web.UI.WebControls.WebParts Line 34: Imports System.Xml.Linq Line 35: Line 36: Namespace ASP Line 37: Line 38: <System.Runtime.CompilerServices.CompilerGlobalScopeAttribute()> _ Line 39: Public Class include_functions_aspx Line 40: Inherits Global.System.Web.UI.Page Line 41: Implements System.Web.SessionState.IRequiresSessionState, System.Web.IHttpHandler Line 42: Line 43: Private Shared __initialized As Boolean Line 44: Line 45: Private Shared __fileDependencies As Object Line 46: Line 47: Line 48: #ExternalSource("D:\home\site\wwwroot\include\functions.aspx",2) Line 49: Line 50: Dim geoIpTable As String = "B" Line 51: Line 52: Function getIpAddress() As String Line 53: Dim context As System.Web.HttpContext = System.Web.HttpContext.Current Line 54: Dim tmpIp As String = context.Request.ServerVariables("HTTP_X_FORWARDED_FOR") Line 55: Dim ipFinal As String Line 56: Line 57: If tmpIp <> Nothing Line 58: Dim ipArray As String() = tmpIp.Split(",") Line 59: ipFinal = (ipArray(ipArray.Length-1) & "").Replace("'", "''").Trim() Line 60: End If Line 61: Line 62: If ipFinal = Nothing Line 63: ipFinal = context.Request.ServerVariables("REMOTE_ADDR") Line 64: End If Line 65: Line 66: If ipFinal = Nothing Line 67: ipFinal = HttpContext.Current.Request.UserHostAddress Line 68: End If Line 69: Line 70: If ipFinal.IndexOf(":") > -1 Line 71: ipFinal = ipFinal.SubString(0, ipFinal.IndexOf(":")) Line 72: End If Line 73: Line 74: Return ipFinal Line 75: End Function Line 76: Line 77: Sub GetLocation() Line 78: Dim latCookie As HttpCookie=Request.Cookies("Latitude") Line 79: Dim lngCookie As HttpCookie=Request.Cookies("Longitude") Line 80: Line 81: If Not latCookie Is Nothing And Not lngCookie Is Nothing And Request.Querystring("nolocation") <> "nolocation" Line 82: Try Line 83: userLat = latCookie.Value Line 84: userLng = lngCookie.Value Line 85: userLocation = Request.Cookies("Location").Value.ToString().Replace("_", " ") Line 86: Catch Line 87: Line 88: End Try Line 89: ElseIf IsBot() = False And Request.Querystring("nolocation") <> "nolocation" Line 90: Dim ip As String = getIpAddress() ''//Request.ServerVariables("REMOTE_ADDR") Line 91: If ip.IndexOf("192.168.1.") > -1 Then ip = "47.21.19.98" Line 92: Dim ipArray() As String = ip.Split(".") Line 93: Dim locationValue As Int64, z As Int32, invalidLocation As Boolean Line 94: Line 95: For Each i As String In ipArray Line 96: If Not IsNumeric(i) Line 97: Exit For Line 98: End If Line 99: Line 100: z += 1 Line 101: Line 102: Select Case z Line 103: Case 1 Line 104: locationValue = Convert.ToInt64(i) * 16777216 Line 105: Case 2 Line 106: locationValue += Convert.ToInt64(i) * 65536 Line 107: Case 3 Line 108: ''//locationValue += Convert.ToInt64(i) * 97 Line 109: locationValue += Convert.ToInt64(i) * 256 Line 110: Case 4 Line 111: locationValue += Convert.ToInt64(i) Line 112: Case Else Line 113: invalidLocation = True Line 114: Exit For Line 115: End Select Line 116: Next Line 117: Line 118: If locationValue > 0 And invalidLocation = False Line 119: Dim conn_ull As New SqlConnection(Application("ConnectionString")) Line 120: Dim cmd_ull As New SqlCommand() Line 121: Line 122: cmd_ull.CommandText = "GetGeoIP2Location" Line 123: cmd_ull.CommandType = System.Data.CommandType.StoredProcedure Line 124: cmd_ull.Connection = conn_ull Line 125: Line 126: cmd_ull.Parameters.Add("@LocationValue", System.Data.SqlDbType.BigInt) Line 127: cmd_ull.Parameters("@LocationValue").Value = locationValue Line 128: Line 129: conn_ull.Open() Line 130: Line 131: Dim reader_ull As SqlDataReader = cmd_ull.ExecuteReader() Line 132: Line 133: If reader_ull.Read() Line 134: Dim country, region, city, zip, location As String, lat, lng As Decimal Line 135: Line 136: country = reader_ull("Country").ToString() Line 137: region = reader_ull("Region").ToString() Line 138: city = reader_ull("City").ToString() Line 139: zip = reader_ull("Zip").ToString() Line 140: lat = reader_ull("Latitude").ToString() Line 141: lng = reader_ull("Longitude").ToString() Line 142: Line 143: If lat <> 0 And lng <> 0 Line 144: If country = "United States" Or country = "Canada" Line 145: If region <> "" And city <> "" Line 146: location = city & ", " & region Line 147: ElseIf region <> "" Line 148: location = region & ", " & country Line 149: End If Line 150: Line 151: lat = reader_ull("Latitude") Line 152: lng = reader_ull("Longitude") Line 153: Else Line 154: If city <> "" And country <> "" Line 155: If region <> "" Line 156: location = city & ", " & region & ", " & country Line 157: Else Line 158: location = city & ", " & country Line 159: End If Line 160: End If Line 161: End If Line 162: Line 163: If location <> "" Line 164: Response.Cookies("Latitude").Expires=Today.AddDays(40) Line 165: Response.Cookies("Latitude").Value=lat Line 166: userLat = lat Line 167: Line 168: Response.Cookies("Longitude").Expires=Today.AddDays(40) Line 169: Response.Cookies("Longitude").Value=lng Line 170: userLng = lng Line 171: Line 172: Response.Cookies("Location").Expires=Today.AddDays(40) Line 173: Response.Cookies("Location").Value=location.Replace(" ", "_") Line 174: userLocation = location Line 175: End If Line 176: End If Line 177: End If Line 178: Line 179: reader_ull.Close() : cmd_ull.Dispose() : conn_ull.Close() : conn_ull.Dispose() Line 180: End If Line 181: End If Line 182: Line 183: ''//userLat = 38.631034 Line 184: ''//userLng = -90.1931066 Line 185: ''//userLocation = "Saint Louis, MO" Line 186: Line 187: If userLocation = "" Line 188: userLocation = "Edit Location" Line 189: Else Line 190: If userLocation.IndexOf(",") > -1 Line 191: userLocationCity = userLocation.SubString(0, userLocation.IndexOf(",")) Line 192: userLocationState = userLocation.SubString(userLocation.IndexOf(",")) Line 193: userLocationState = userLocationState.Trim(",") Line 194: userLocationState = userLocationState.Trim() Line 195: End If Line 196: End If Line 197: End Sub Line 198: Line 199: Function GetLocationByIp(ByVal ip As String) As String Line 200: Dim location As String = "" Line 201: Line 202: If IsBot() = False Line 203: Dim ipArray() As String = ip.Split(".") Line 204: Dim locationValue As Int64, z As Int32, invalidLocation As Boolean Line 205: Line 206: For Each i As String In ipArray Line 207: If Not IsNumeric(i) Line 208: Exit For Line 209: End If Line 210: Line 211: z += 1 Line 212: Line 213: Select Case z Line 214: Case 1 Line 215: locationValue = Convert.ToInt64(i) * 16777216 Line 216: Case 2 Line 217: locationValue += Convert.ToInt64(i) * 65536 Line 218: Case 3 Line 219: ''//locationValue += Convert.ToInt64(i) * 97 Line 220: locationValue += Convert.ToInt64(i) * 256 Line 221: Case 4 Line 222: locationValue += Convert.ToInt64(i) Line 223: Case Else Line 224: invalidLocation = True Line 225: Exit For Line 226: End Select Line 227: Next Line 228: Line 229: If locationValue > 0 And invalidLocation = False Line 230: Dim strSQL_ull As String="SELECT L.CountryName AS Country, L.SubDivision1IsoCode AS Region, L.CityName AS City, B.PostalCode AS Zip, B.Latitude, B.Longitude " & _ Line 231: "FROM GeoIP2Blocks B " & _ Line 232: "INNER JOIN GeoIP2Locations L ON L.GeoNameID = B.GeoNameID " & _ Line 233: "WHERE (" & locationValue & " BETWEEN B.NetworkStartInteger AND B.NetworkLastInteger) AND (L.CityName <> '')" Line 234: Line 235: Dim objConn_ull As New SqlConnection(Application("ConnectionStringReadOnly")) Line 236: Dim objCmd_ull As New SqlCommand(strSQL_ull, objConn_ull) Line 237: Line 238: objConn_ull.Open() Line 239: Line 240: Dim objR_ull As SqlDataReader=objCmd_ull.ExecuteReader() Line 241: Line 242: If objR_ull.Read() Line 243: Dim country, region, city, zip As String, lat, lng As Decimal Line 244: Line 245: country = objR_ull("Country").ToString() Line 246: region = objR_ull("Region").ToString() Line 247: city = objR_ull("City").ToString() Line 248: zip = objR_ull("Zip").ToString() Line 249: lat = objR_ull("Latitude").ToString() Line 250: lng = objR_ull("Longitude").ToString() Line 251: Line 252: If lat <> 0 And lng <> 0 Line 253: If country = "United States" Or country = "Canada" Line 254: If region <> "" And city <> "" Line 255: location = city & ", " & region Line 256: ElseIf region <> "" Line 257: location = region & ", " & country Line 258: End If Line 259: Line 260: lat = objR_ull("Latitude") Line 261: lng = objR_ull("Longitude") Line 262: Else Line 263: If city <> "" And country <> "" Line 264: If region <> "" Line 265: location = city & ", " & region & ", " & country Line 266: Else Line 267: location = city & ", " & country Line 268: End If Line 269: End If Line 270: End If Line 271: End If Line 272: End If Line 273: Line 274: objR_ull.Close() : objCmd_ull.Dispose() : objConn_ull.Close() : objConn_ull.Dispose() Line 275: End If Line 276: End If Line 277: Line 278: Return(location) Line 279: End Function Line 280: Line 281: Function reviewStars(ByVal score As Single) As String Line 282: Select Case score Line 283: Case >= 4.75 Line 284: Return("<i class=""fa fa-star""></i><i class=""fa fa-star""></i><i class=""fa fa-star""></i><i class=""fa fa-star""></i><i class=""fa fa-star""></i>") Line 285: Case >= 4.25 Line 286: Return("<i class=""fa fa-star""></i><i class=""fa fa-star""></i><i class=""fa fa-star""></i><i class=""fa fa-star""></i><i class=""fa fa-star-half-o""></i>") Line 287: Case >= 3.75 Line 288: Return("<i class=""fa fa-star""></i><i class=""fa fa-star""></i><i class=""fa fa-star""></i><i class=""fa fa-star""></i><i class=""fa fa-star-o""></i>") Line 289: Case >= 3.25 Line 290: Return("<i class=""fa fa-star""></i><i class=""fa fa-star""></i><i class=""fa fa-star""></i><i class=""fa fa-star-half-o""></i><i class=""fa fa-star-o""></i>") Line 291: Case >= 2.75 Line 292: Return("<i class=""fa fa-star""></i><i class=""fa fa-star""></i><i class=""fa fa-star""></i><i class=""fa fa-star-o""></i><i class=""fa fa-star-o""></i>") Line 293: Case >= 2.25 Line 294: Return("<i class=""fa fa-star""></i><i class=""fa fa-star""></i><i class=""fa fa-star-half-o""></i><i class=""fa fa-star-o""></i><i class=""fa fa-star-o""></i>") Line 295: Case >= 1.75 Line 296: Return("<i class=""fa fa-star""></i><i class=""fa fa-star""></i><i class=""fa fa-star-o""></i><i class=""fa fa-star-o""></i><i class=""fa fa-star-o""></i>") Line 297: Case >= 1.25 Line 298: Return("<i class=""fa fa-star""></i><i class=""fa fa-star-half-o""></i><i class=""fa fa-star-o""></i><i class=""fa fa-star-o""></i><i class=""fa fa-star-o""></i>") Line 299: Case >= .75 Line 300: Return("<i class=""fa fa-star""></i><i class=""fa fa-star-o""></i><i class=""fa fa-star-o""></i><i class=""fa fa-star-o""></i><i class=""fa fa-star-o""></i>") Line 301: Case >= .25 Line 302: Return("<i class=""fa fa-star-half-o""></i><i class=""fa fa-star-o""></i><i class=""fa fa-star-o""></i><i class=""fa fa-star-o""></i><i class=""fa fa-star-o""></i>") Line 303: Case Else Line 304: Return("<i class=""fa fa-star-o""></i><i class=""fa fa-star-o""></i><i class=""fa fa-star-o""></i><i class=""fa fa-star-o""></i><i class=""fa fa-star-o""></i>") Line 305: End Select Line 306: End Function Line 307: Line 308: Function IsKnownBot() As Boolean Line 309: Dim strRobotsArray As String() = {"bingbot", "googlebot", "uptimerobot", "blexbot", "testomatobot", "yandex", "baidu", "pingoscope", "mj12bot", "exabot", _ Line 310: "omgilibot", "dotbot", "ccbot", "ahrefsbot", "archive.org", "special_archiver", "slurp", "linkdexbot", "seznambot", "psbot", "seokicks", "yeti", _ Line 311: "coccoc", "metajobbot", "superarama", "changedetection", "msnbot", "domainappender", "lipperhey", "vagabondo", "woko", "thumbsniper", "mail.ru", _ Line 312: "ichiro", "sogou", "gigablast", "360spider", "smtbot", "obot", "netsteer", "proximic", "zumbot", "sitedomain-bot", "mojeek", "searchmetrics", _ Line 313: "genieo", "sentibot", "openlinkprofiler", "james bot", "spinn3r", "wesee", "wevika", "semrush", "applebot", "daumoa", "deadlinkchecker", _ Line 314: "tools4noobs", "web-sniffer", "motoricerca", "robots_tester", "promotion_tools", "whatsmyip", "meanpathbot", "secretsearchenginelabs", "gimme", _ Line 315: "yooz", "grapeshot", "w3dt", "wotbox", "voltron", "expertsearch", "orangebot", "voilabot", "orangecrawler", "mindup", "stq_bot", "blekkobot", _ Line 316: "seodiver", "riddler", "speedy spider", "sputnikbot", "cliqzbot", "nalezen", "seocheck", "tagseobot", "aihit", "chlooe", "coincorner", "netestate", _ Line 317: "producto", "flipboard", "steeler", "kraken", "rogerbot", "showyou", "bitlybot", "gtmetrix", "icjobs", "comodo", "wi job", "megaindex", "jyxobot", _ Line 318: "linkapedia", "zeerch", "xovibot", "idmarch", "bad-neighborhood", "antbot", "semanticscholar", "linkmarket", "rankflex", "bdcbot", "wbsrch", _ Line 319: "link valet", "page valet", "dlcbot", "online domain tools", "kumkie", "crawler4j", "bcklinks", "web-sniffer", "404 checker", "lcc", "heritrix", _ Line 320: "yacybot", "alexabot", "alexa site audit", "heartrails", "geturlinfo", "facebookexternalhit", "aboundex", "pagespeed", "yioop", "govid.mobi", _ Line 321: "panscient", "duckduckgo", "duckduckbot", "netcraftsurvey", "plukkie", "backlinkcrawler", "woriobot", "semantic-visions", "wbsearchbot", _ Line 322: "gluten free crawler", "turnitinbot", "umbot-fc", "umbot-ln", "linktiger", "spiderling", "2bone_link", "powermapper", "brokenlinkcheck", "zoominfo", _ Line 323: "nextgensearchbot", "bubing", "implisensebot", "experibot", "uaslinkchecker", "thumbshots", "apercite", "webmastercoffee", "waseda", "exactseek", _ Line 324: "007ac9", "tweetmemebot", "impressumscrawler", "vorboss", "seograph", "safesearch microdata", "safesearch.avira.com", "mixbot", "parsijoo", _ Line 325: "easou", "r6_comment", "r6_feed", "domaintuno", "worldbrewbot", "seobility", "urlstat", "integromedb", "port-monitor.com", "port monitor check service", _ Line 326: "kimonolabs", "icc-crawler", "loadimpact", "websnapr", "cukbot", "memorybot", "qwantify", "trendiction", "natlib.gov", "uptimedog", "gecko webthumb", _ Line 327: "linkpeek", "hosttracker", "ia_archiver", "bdfetch", "metaspider", "site24x7", "it2media", "pandeo", "agentslug.com", "siteliner", "sistrix", _ Line 328: "mnogosearch", "aboutusbot", "jobdiggerspider", "istellabot", "sukibot", "hubspot", "optimizationcrawler", "abrave v", "abrave spider", "leikibot", _ Line 329: "gozaikbot", "botlink", "ahoy!", "alkalinebot", "anthillv", "appie/", "arachnophilia", "araneo", "araybOt", "architextspider", "ariadne", "arks/", _ Line 330: "aspider/", "atn_worldwide", "atomz/", "auresys/", "backrub/", "bayspider", "bbot/", "big brother", "bjaaland/", "blackwidow", "die blinde kuh", _ Line 331: "ukonline", "borg-bot/", "boxseabot/", "bspider/", "cactvs", "calif/", "digimarc", "checkbot/", "christcrawler", "cienciaficcion", "cmc/", _ Line 332: "conceptbot/", "confuzzledbot/", "coolbot", "cosmos/", "internet cruiser robot", "cusco/", "cyberspyder/", "cydralspider/", "desertrealm", "deweb/", _ Line 333: "dienstspider/1.0", "digger/", "diibot", "grabber", "dnabot/", "dragonbot/", "dwcp/", "lwp:", "ebiness", "eit-link-verifier", "elfinbot", "emacs-", _ Line 334: "emc spider", "esculapio", "evliya celebi", "explorersearch", "fastcrawler", "fdse robot", "felixide", "hazel's ferret", "esirover", "fido/", _ Line 335: "hämähäkki/", "kit-fireball", "fish-search", "fouineur", "robot du crim", "freecrawl", "funnelweb-", "gammaspider", "gazz/", "gcreep/", "geturl.rexx", _ Line 336: "golem/", "griffon/", "gromit/", "gulliver/", "gulper web bot", "havindex/", "aitcsrobot/", "hometown spider pro", "wired-digital-newsbot/", _ Line 337: "htdig/", "htmlgobble", "iajaBot/", "ibm_planetwide", "gestalticonoclast", "ingrid/", "incywincy", "infoseek", "infospiders/", "inspectorwww/", _ Line 338: "iron33/", "israelisearch/", "javabee", "jcrawler/", "ask jeeves", "jobot/", "joebot/", "jubiirobot", "jumpstation", "image.kapsi.net", "katipo/", _ Line 339: "kdd-explorer/", "ko_yappo_robot", "labelgrab/", "larbin (+mail)", "linkidator/", "linkscan server", "Linkwalker", "lockon/", "logo.gif crawler", _ Line 340: "lycos/", "magpie/", "marvin/infoseek", "mediafox/", "merzscope", "nec-meshexplorer", "mindcrawler", "udmsearch", "moget/", "momspider/", "muninn/", _ Line 341: "muscatferret", "mwdsearch/", "sharp-info-agent", "ndspider/", "etcarta cyberpilot", "netmechanic", "netscoop/", "newscan-online/", "nhsewalker/", _ Line 342: "nomad-v", "objectssearch/", "occam/", "hku www robot", "ontospider/", "openbot", "orbsearch", "packrat/", "pageboy/", "parasite/", "patric/", _ Line 343: "web robot pegasus", "peregrinator-mathematics", "perlcrawler", "duppies", "phpdig", "piltdownman", "pimptrain", "portaljuice.com", "pgp-ka/", _ Line 344: "plumtreewebaccessor", "poppi/", "portalbspider/", "psbot/", "getterroboplus", "raven-v", "resume robot", "rhcs/", "rixbot", "imagescape robot", _ Line 345: "robbie/", "computingsite robi", "robocrawl (", "robofox v", "robozilla/", "roverbot", "safetynet robot", "scooter/", "sleek spider", _ Line 346: "searchprocess/", "senrigan/", "sg-scout", "shagseeker", "shai'hulud", "libwww-perl-", "simbot/", "site valet", "open text site crawler", _ Line 347: "sitetech-rover", "awapclient", "slcrawler", "esismartspider", "snooper/", "solbot/", "spanner/", "speedy spider", "mouse.house/", "spiderbot/", _ Line 348: "spiderline/", "spiderview", "ssearcher100", "suke/", "suntek/", "sygol.com", "black widow v", "tarantula/", "tarspider", "dlw3robot/", "techbot", _ Line 349: "templeton/", "teoma_agent1", "titin/", "titan/", "tlspider/", "ucsd-crawler", "udmsearch/", "uptimebot", "urlck/", "url spider pro", "valkyrie/", _ Line 350: "verticrawlbot", "victoria/", "vision-search/", "void-bot/", "vwbot_k", "w3index", "w3m2/", "crawlpaper/", "wwwanderer v", "w@pspider/", _ Line 351: "webbandit/", "webcatcher/", "webcopy/", "webfetcher/", "weblayers/", "weblinker/", "webmoose/", "webquest/", "digimarc webreader/", "webreaper", _ Line 352: "webs@recruit.co.jp", "webvac/", "webwalk", "webwalker/", "wget/", "whatuseek_winona", "wlm-", "w3mir", "wolp/", "wwwc/", "nederland.zoek", _ Line 353: "montastic", "majestic12", "nerdybot", "python-urllib", "tbot-nutch", "twitterbot", "domainreanimator", _ Line 354: "yisouspider", "linkwalker", "google favicon", "scrapy.org", "paperlibot", "phpcrawl", "pinterest", _ Line 355: "python-urllib/2.7", "feedfetcher-google", "netlyzer", "python-requests", "google-site-verification", _ Line 356: "semanticbot", "siteexplorer.info", "linkpadbot/", "businessbot:", "weborama-fetcher", "go-http-client/", "stratagems kumo", "betabot", _ Line 357: "linguee bot", "seoscanners", "findxbot", "bomborabot", "15miles.com", "ips-agent", "dataprovider.com", "extlinksbot", "toweya", "ltx71", _ Line 358: "code.google.com/appengine; appid: s~snapchat-proxy)", "safednsbot", "pcore-http", "8legs", "redback/", "saleslift", "daum/", "headmasterseo", _ Line 359: "metauri.com", "sitelockspider", "domainstatsbot", "id-search.xyz", "gookey.co/", "xenu link sleuth", "uipbot/", "scoutjet.com", _ Line 360: "techinfo@ubermetrics-technologies.com", "catexplorador", "datagnionbot", "peet browser", "blackboard safeassign", "/nutch-", "rankingbot2", _ Line 361: "linkfluence.com", "www-mechanize/", "zibalinks", "wonderbot/", "teeraidbot", "xml-sitemaps.com", "okhttp/", "screaming frog", "smurlexpander", _ Line 362: "go 1.1 package http", "client/research_scan", "checkmarknetwork", "superpagesurlverifybot", "; linkcheckv", "scrapy-redis", "faraday v", _ Line 363: "www.x9o.de", "nettrack.info", "veoozbot", "seozoom", "s~buzzstream-tools-hrd", "redirector/1.1", "github.com/aliasio/wappalyzer", _ Line 364: "thunderstone.com", "g-i-g-a-b-o-t", "seoterritory.com", "feedparser.org", "salesintelligent", "licvb.wpengine.com", _ Line 365: "dnyzbot/", "watson-url-fetcher", "clickagy intelligence bot", "gowikibot/", "pipl.com", "barkrowler", "buff library user agent", "rssingbot", _ Line 366: "mediapartners-google", "node-urllib", "guzzlehttp", "symfony browserkit", "a6-indexer", "sirdatabot", _ Line 367: "superfeedr bot/", "jersey/2.25.1 (apache httpclient 4.5)", "python/3.6 aiohttp/", "software.schmorp.de/", _ Line 368: "http://researchscan.comsys.rwth-aachen.de)", "mozilla/3.0 (compatible; indy library)", "ahc/2.1", _ Line 369: "nimbostratus-bot/v", "apache-httpclient/", "zgrab/", "industryindexbot/", "libcurl/", "wappalyzer", _ Line 370: "sitechecker", "surdotlybot/", "urltester/", "webdatastats/", "mainwp/", "leadssearchspider", "v-bot/", "honeybee ver. ", "b2b bot", _ Line 371: "trendsmapresolver/", "gigabot", "winhttp.winhttprequest.", "spuhex.com", "universalfeedparser/", "dcrawl/", "prlog.ru", "tracemyfile/", _ Line 372: "econtext/", "voluumdsp-content-bot/", "httpscheck (", "opebot (", "sitetruth.com", "hybridbot", "re-re studio", "grammarly/", _ Line 373: "28logsspider", "bot annuairefrancais.", "ocarinabot", "newspaper/0", "redditbot/", "mappy/", "dispatch/0", "lookseek.com", _ Line 374: "tweetedtimes.com", "orgprobe/", "com.plumanalytics", "easybib autocite", "cakephp", "mediatoolkitbot", "jooblebot", "adsbot-google", _ Line 375: "wordpress/", "dispatch/", "mixnodecache/", "evc-batch/2.0)", "woorankreview/", "everyonedomainsbot/", "tweezler/", "di-cloud-parser", _ Line 376: "acebookexternalhit/", "node-fetch/", "deeris/", "react/alpha", "outclicksbot/", "httpclient/1.", "bublupbot", "thither.direct bot/", _ Line 377: "serpstatbot/", "jdatabasedrivermysqli", "vuhuvbot/", "pandalytics/", "who.is bot", "dun&bradstreetbot/", "coraxcyber.com", "node-superagent/", _ Line 378: "reqwest/", "bublup.com", "7siters/", "crowdtanglebot/", "my user agent name", "chimebot", "pleskbot", "cloudfind/", "scrapybot (", "clarabot/", _ Line 379: "awariosmartbot/", "sjuupbot", "linkedinbot/", "brands-bot", "adsbot/)", "bananabot/", "aspiegelbot)", "keybot translation", "jetmon/", _ Line 380: "centuryb.o.t", "turnitin (", "research-project-bot", "linespider/", "bitdiscovery", "myseosnapshot/", "axios/", "yelpbot", "hotbot", _ Line 381: "go http package", "phpwebsite/", "rustbot/", "hexometer", "niuebot/", " adsbot/", "hypefactors.com", "admantx", "domainsproject.org", _ Line 382: "censys.io", "htmlparser/", "intelx.io_bot", "embarcadero", "webtech/", "polyapp-website-analysis"} Line 383: Line 384: Dim strFilterUserAgent As String = (Request.ServerVariables("HTTP_USER_AGENT") & "").ToLower() Line 385: Line 386: Dim blnIsARobot As Boolean = False Line 387: Line 388: If strFilterUserAgent=Nothing Then blnIsARobot = True Line 389: Line 390: Dim i_robot As String Line 391: Line 392: If strFilterUserAgent <> "" Line 393: If strFilterUserAgent.Length > 5 Line 394: If strFilterUserAgent.SubString(0, 5) = "java/" Or strFilterUserAgent.SubString(0, 5) = "curl/" Line 395: blnIsARobot = True Line 396: End If Line 397: End If Line 398: End If Line 399: Line 400: If strFilterUserAgent = "null" Or strFilterUserAgent = "foo" Or strFilterUserAgent = "ruby" Or strFilterUserAgent = "mozilla/5.0 (compatible; optimizer)" Or strFilterUserAgent = "n/a" Line 401: blnIsARobot = True Line 402: Else Line 403: For Each i_robot In strRobotsArray Line 404: If strFilterUserAgent.IndexOf(i_robot) > -1 Line 405: blnIsARobot = True Line 406: Exit For Line 407: End If Line 408: Next Line 409: End If Line 410: Line 411: Return(blnIsARobot) Line 412: End Function Line 413: Line 414: Function IsBot() As Boolean Line 415: Dim objBrowserCaps As System.Web.HttpBrowserCapabilities = Request.Browser Line 416: Dim blnIsBot As Boolean = (CType(objBrowserCaps, System.Web.Configuration.HttpCapabilitiesBase)).Crawler Line 417: Line 418: If blnIsBot = False Line 419: Dim blnIsBot2 As Boolean = IsKnownBot() Line 420: Line 421: If blnIsBot2 Then blnIsBot = True Line 422: End If Line 423: Line 424: If Not blnIsBot Line 425: Dim uA As String = (Request.ServerVariables("HTTP_USER_AGENT") & "").ToLower() Line 426: Line 427: If uA.IndexOf("windows")=-1 And uA.IndexOf("applewebkit")=-1 And uA.IndexOf("thunderbird/")=-1 And uA.IndexOf("applewebkit")=-1 And uA.IndexOf("thunderbird/")=-1 And uA.IndexOf("msie")=-1 And uA.IndexOf("opera")=-1 And uA.IndexOf("safari")=-1 And uA.IndexOf("android")=-1 And uA.IndexOf("firefox")=-1 And uA.IndexOf("chrome")=-1 And uA.IndexOf("iphone")=-1 Line 428: If uA.Length > 100 Then uA = uA.SubString(0, 99) Line 429: ''//ExecNonQuery("INSERT INTO UserAgents(Agent, IP) VALUES('" & uA.Replace("'", "''") & "', '" & Request.ServerVariables("REMOTE_ADDR") & "')") Line 430: End If Line 431: End If Line 432: Line 433: Return(blnIsBot) Line 434: End Function Line 435: Line 436: Function ExecScalar(ByVal strQuery As String) As String Line 437: If strQuery.Length>0 Line 438: Dim objConn As New SqlConnection(Application("ConnectionString")) Line 439: Dim objCmd As New SqlCommand(strQuery, objConn) Line 440: Line 441: objConn.Open() Line 442: Line 443: Dim strResult As String=objCmd.ExecuteScalar() Line 444: Line 445: objCmd.Dispose() : objConn.Close() : objConn.Dispose() Line 446: Line 447: Return strResult Line 448: Else Line 449: Return Nothing Line 450: End If Line 451: End Function Line 452: Line 453: Sub ExecNonQuery(ByVal strQuery As String) Line 454: If strQuery.Length>0 Line 455: Dim objConn As New SqlConnection(Application("ConnectionString")) Line 456: Dim objCmd As New SqlCommand(strQuery, objConn) Line 457: Line 458: objConn.Open() : objCmd.ExecuteNonQuery() Line 459: Line 460: objCmd.Dispose() : objConn.Close() : objConn.Dispose() Line 461: End If Line 462: End Sub Line 463: Line 464: Function F(ByVal strF As String) As String Line 465: If Request(strF)=Nothing Line 466: Return("'', ") Line 467: Else Line 468: Return("'" & Request(strF).ToString().Replace("'", "''") & "', ") Line 469: End If Line 470: End Function Line 471: Line 472: Function F2(ByVal strF As String) As String Line 473: If Request(strF)=Nothing Line 474: Return("''") Line 475: Else Line 476: Return("'" & Request(strF).ToString().Replace("'", "''") & "'") Line 477: End If Line 478: End Function Line 479: Line 480: Function stripHtml(ByVal Y As String) As String Line 481: Dim R As RegEx Line 482: Line 483: If Y = Nothing Then Return("") Line 484: Line 485: Y=R.Replace(Y, "<[^>]*(>|$)", "") Line 486: Line 487: Return(Y) Line 488: End Function Line 489: Line 490: Function getStateSmall(ByVal strState As String) Line 491: Select Case (strState & "").ToLower() Line 492: Case "alabama" Line 493: Return("AL") Line 494: Case "alaska" Line 495: Return("AK") Line 496: Case "arizona" Line 497: Return("AZ") Line 498: Case "arkansas" Line 499: Return("AR") Line 500: Case "california" Line 501: Return("CA") Line 502: Case "colorado" Line 503: Return("CO") Line 504: Case "connecticut" Line 505: Return("CT") Line 506: Case "delaware" Line 507: Return("DE") Line 508: Case "district of columbia", "district-of-columbia" Line 509: Return("DC") Line 510: Case "florida" Line 511: Return("FL") Line 512: Case "georgia" Line 513: Return("GA") Line 514: Case "hawaii" Line 515: Return("HI") Line 516: Case "idaho" Line 517: Return("ID") Line 518: Case "illinois" Line 519: Return("IL") Line 520: Case "indiana" Line 521: Return("IN") Line 522: Case "iowa" Line 523: Return("IA") Line 524: Case "kansas" Line 525: Return("KS") Line 526: Case "kentucky" Line 527: Return("KY") Line 528: Case "louisiana" Line 529: Return("LA") Line 530: Case "maine" Line 531: Return("ME") Line 532: Case "maryland" Line 533: Return("MD") Line 534: Case "massachusetts" Line 535: Return("MA") Line 536: Case "michigan" Line 537: Return("MI") Line 538: Case "minnesota" Line 539: Return("MN") Line 540: Case "mississippi" Line 541: Return("MS") Line 542: Case "missouri" Line 543: Return("MO") Line 544: Case "montana" Line 545: Return("MT") Line 546: Case "nebraska" Line 547: Return("NE") Line 548: Case "nevada" Line 549: Return("NV") Line 550: Case "new hampshire", "new-hampshire" Line 551: Return("NH") Line 552: Case "new jersey", "new-jersey" Line 553: Return("NJ") Line 554: Case "new mexico", "new-mexico" Line 555: Return("NM") Line 556: Case "new york", "new-york" Line 557: Return("NY") Line 558: Case "north carolina", "north-carolina" Line 559: Return("NC") Line 560: Case "north dakota", "north-dakota" Line 561: Return("ND") Line 562: Case "ohio" Line 563: Return("OH") Line 564: Case "oklahoma" Line 565: Return("OK") Line 566: Case "oregon" Line 567: Return("OR") Line 568: Case "pennsylvania" Line 569: Return("PA") Line 570: Case "puerto rico", "puerto-rico" Line 571: Return("PR") Line 572: Case "rhode island", "rhode-island" Line 573: Return("RI") Line 574: Case "south carolina", "south-carolina" Line 575: Return("SC") Line 576: Case "south dakota", "south-dakota" Line 577: Return("SD") Line 578: Case "tennessee" Line 579: Return("TN") Line 580: Case "texas" Line 581: Return("TX") Line 582: Case "utah" Line 583: Return("UT") Line 584: Case "vermont" Line 585: Return("VT") Line 586: Case "virginia" Line 587: Return("VA") Line 588: Case "washington" Line 589: Return("WA") Line 590: Case "west virginia", "west-virginia" Line 591: Return("WV") Line 592: Case "wisconsin" Line 593: Return("WI") Line 594: Case "wyoming" Line 595: Return("WY") Line 596: Case "alberta" Line 597: Return("AB") Line 598: Case "british-columbia" Line 599: Return("BC") Line 600: Case "manitoba" Line 601: Return("MB") Line 602: Case "new-brunswick" Line 603: Return("NB") Line 604: Case "newfoundland", "newfoundland-and-labrador" Line 605: Return("NL") Line 606: Case "nova-scotia" Line 607: Return("NS") Line 608: Case "northwest-territories" Line 609: Return("NT") Line 610: Case "nunavut" Line 611: Return("NU") Line 612: Case "ontario" Line 613: Return("ON") Line 614: Case "prince-edward-island" Line 615: Return("PE") Line 616: Case "quebec" Line 617: Return("QC") Line 618: Case "saskatchewan" Line 619: Return("SK") Line 620: Case "yukon" Line 621: Return("YT") Line 622: Case Else Line 623: Return("") Line 624: End Select Line 625: End Function Line 626: Line 627: Function getStatePath(ByVal strState As String) Line 628: Select Case (strState & "").ToUpper() Line 629: Case "AL" Line 630: Return("alabama") Line 631: Case "AK" Line 632: Return("alaska") Line 633: Case "AZ" Line 634: Return("arizona") Line 635: Case "AR" Line 636: Return("arkansas") Line 637: Case "CA" Line 638: Return("california") Line 639: Case "CO" Line 640: Return("colorado") Line 641: Case "CT" Line 642: Return("connecticut") Line 643: Case "DE" Line 644: Return("delaware") Line 645: Case "DC" Line 646: Return("district-of-columbia") Line 647: Case "FL" Line 648: Return("florida") Line 649: Case "GA" Line 650: Return("georgia") Line 651: Case "HI" Line 652: Return("hawaii") Line 653: Case "ID" Line 654: Return("idaho") Line 655: Case "IL" Line 656: Return("illinois") Line 657: Case "IN" Line 658: Return("indiana") Line 659: Case "IA" Line 660: Return("iowa") Line 661: Case "KS" Line 662: Return("kansas") Line 663: Case "KY" Line 664: Return("kentucky") Line 665: Case "LA" Line 666: Return("louisiana") Line 667: Case "ME" Line 668: Return("maine") Line 669: Case "MD" Line 670: Return("maryland") Line 671: Case "MA" Line 672: Return("massachusetts") Line 673: Case "MI" Line 674: Return("michigan") Line 675: Case "MN" Line 676: Return("minnesota") Line 677: Case "MS" Line 678: Return("mississippi") Line 679: Case "MO" Line 680: Return("missouri") Line 681: Case "MT" Line 682: Return("montana") Line 683: Case "NE" Line 684: Return("nebraska") Line 685: Case "NV" Line 686: Return("nevada") Line 687: Case "NH" Line 688: Return("new-hampshire") Line 689: Case "NJ" Line 690: Return("new-jersey") Line 691: Case "NM" Line 692: Return("new-mexico") Line 693: Case "NY" Line 694: Return("new-york") Line 695: Case "NC" Line 696: Return("north-carolina") Line 697: Case "ND" Line 698: Return("north-dakota") Line 699: Case "OH" Line 700: Return("ohio") Line 701: Case "OK" Line 702: Return("oklahoma") Line 703: Case "OR" Line 704: Return("oregon") Line 705: Case "PA" Line 706: Return("pennsylvania") Line 707: Case "PR" Line 708: Return("puerto-rico") Line 709: Case "RI" Line 710: Return("rhode-island") Line 711: Case "SC" Line 712: Return("south-carolina") Line 713: Case "SD" Line 714: Return("south-dakota") Line 715: Case "TN" Line 716: Return("tennessee") Line 717: Case "TX" Line 718: Return("texas") Line 719: Case "UT" Line 720: Return("utah") Line 721: Case "VT" Line 722: Return("vermont") Line 723: Case "VA" Line 724: Return("virginia") Line 725: Case "WA" Line 726: Return("washington") Line 727: Case "WV" Line 728: Return("west-virginia") Line 729: Case "WI" Line 730: Return("wisconsin") Line 731: Case "WY" Line 732: Return("wyoming") Line 733: Case "AB" Line 734: Return("alberta") Line 735: Case "BC" Line 736: Return("british-columbia") Line 737: Case "MB" Line 738: Return("manitoba") Line 739: Case "NB" Line 740: Return("new-brunswick") Line 741: Case "NL" Line 742: Return("newfoundland") Line 743: Case "NS" Line 744: Return("nova-scotia") Line 745: Case "NT" Line 746: Return("northwest-territories") Line 747: Case "NU" Line 748: Return("nunavut") Line 749: Case "ON" Line 750: Return("ontario") Line 751: Case "PE" Line 752: Return("prince-edward-island") Line 753: Case "QC" Line 754: Return("quebec") Line 755: Case "SK" Line 756: Return("saskatchewan") Line 757: Case "YT" Line 758: Return("yukon") Line 759: Case Else Line 760: Return("") Line 761: End Select Line 762: End Function Line 763: Line 764: Function getStateLarge(ByVal strState As String) Line 765: Select Case (strState & "").ToUpper() Line 766: Case "AL" Line 767: Return("Alabama") Line 768: Case "AK" Line 769: Return("Alaska") Line 770: Case "AZ" Line 771: Return("Arizona") Line 772: Case "AR" Line 773: Return("Arkansas") Line 774: Case "CA" Line 775: Return("California") Line 776: Case "CO" Line 777: Return("Colorado") Line 778: Case "CT" Line 779: Return("Connecticut") Line 780: Case "DE" Line 781: Return("Delaware") Line 782: Case "DC" Line 783: Return("District of Columbia") Line 784: Case "FL" Line 785: Return("Florida") Line 786: Case "GA" Line 787: Return("Georgia") Line 788: Case "HI" Line 789: Return("Hawaii") Line 790: Case "ID" Line 791: Return("Idaho") Line 792: Case "IL" Line 793: Return("Illinois") Line 794: Case "IN" Line 795: Return("Indiana") Line 796: Case "IA" Line 797: Return("Iowa") Line 798: Case "KS" Line 799: Return("Kansas") Line 800: Case "KY" Line 801: Return("Kentucky") Line 802: Case "LA" Line 803: Return("Louisiana") Line 804: Case "ME" Line 805: Return("Maine") Line 806: Case "MD" Line 807: Return("Maryland") Line 808: Case "MA" Line 809: Return("Massachusetts") Line 810: Case "MI" Line 811: Return("Michigan") Line 812: Case "MN" Line 813: Return("Minnesota") Line 814: Case "MS" Line 815: Return("Mississippi") Line 816: Case "MO" Line 817: Return("Missouri") Line 818: Case "MT" Line 819: Return("Montana") Line 820: Case "NE" Line 821: Return("Nebraska") Line 822: Case "NV" Line 823: Return("Nevada") Line 824: Case "NH" Line 825: Return("New Hampshire") Line 826: Case "NJ" Line 827: Return("New Jersey") Line 828: Case "NM" Line 829: Return("New Mexico") Line 830: Case "NY" Line 831: Return("New York") Line 832: Case "NC" Line 833: Return("North Carolina") Line 834: Case "ND" Line 835: Return("North Dakota") Line 836: Case "OH" Line 837: Return("Ohio") Line 838: Case "OK" Line 839: Return("Oklahoma") Line 840: Case "OR" Line 841: Return("Oregon") Line 842: Case "PA" Line 843: Return("Pennsylvania") Line 844: Case "PR" Line 845: Return("Puerto Rico") Line 846: Case "RI" Line 847: Return("Rhode Island") Line 848: Case "SC" Line 849: Return("South Carolina") Line 850: Case "SD" Line 851: Return("South Dakota") Line 852: Case "TN" Line 853: Return("Tennessee") Line 854: Case "TX" Line 855: Return("Texas") Line 856: Case "UT" Line 857: Return("Utah") Line 858: Case "VT" Line 859: Return("Vermont") Line 860: Case "VA" Line 861: Return("Virginia") Line 862: Case "WA" Line 863: Return("Washington") Line 864: Case "WV" Line 865: Return("West Virginia") Line 866: Case "WI" Line 867: Return("Wisconsin") Line 868: Case "WY" Line 869: Return("Wyoming") Line 870: Case "AB" Line 871: Return("Alberta") Line 872: Case "BC" Line 873: Return("British Columbia") Line 874: Case "MB" Line 875: Return("Manitoba") Line 876: Case "NB" Line 877: Return("New Brunswick") Line 878: Case "NL" Line 879: Return("Newfoundland") Line 880: Case "NS" Line 881: Return("Nova Scotia") Line 882: Case "NT" Line 883: Return("Northwest Territories") Line 884: Case "NU" Line 885: Return("Nunavut") Line 886: Case "ON" Line 887: Return("Ontario") Line 888: Case "PE" Line 889: Return("Prince Edward Island") Line 890: Case "QC" Line 891: Return("Quebec") Line 892: Case "SK" Line 893: Return("Saskatchewan") Line 894: Case "YT" Line 895: Return("Yukon") Line 896: Case Else Line 897: Return("") Line 898: End Select Line 899: End Function Line 900: Line 901: Function SitesStateArray() As String(,) Line 902: Dim statesArray(,) As String = {{"7", "AL", "Alabama"}, {"36", "AK", "Alaska"}, {"84", "AZ", "Arizona"}, {"37", "AR", "Arkansas"}, _ Line 903: {"2", "CA", "California"}, {"45", "CO", "Colorado"}, {"8", "CT", "Connecticut"}, {"3", "DE", "Delaware"}, {"4", "FL", "Florida"}, _ Line 904: {"92", "GA", "Georgia"}, {"38", "HI", "Hawaii"}, {"43", "ID", "Idaho"}, {"51", "IL", "Illinois"}, {"58", "IN", "Indiana"}, _ Line 905: {"57", "IA", "Iowa"}, {"55", "KS", "Kansas"}, {"76", "KY", "Kentucky"}, {"56", "LA", "Louisiana"}, {"44", "ME", "Maine"}, _ Line 906: {"46", "MD", "Maryland"}, {"10", "MA", "Massachusetts"}, {"52", "MI", "Michigan"}, {"26", "MN", "Minnesota"}, {"42", "MS", "Mississippi"}, _ Line 907: {"77", "MO", "Missouri"}, {"41", "MT", "Montana"}, {"35", "NE", "Nebraska"}, {"5", "NV", "Nevada"}, {"39", "NH", "New Hampshire"}, _ Line 908: {"13", "NJ", "New Jersey"}, {"34", "NM", "New Mexico"}, {"20", "NY", "New York"}, {"15", "NC", "North Carolina"}, _ Line 909: {"40", "ND", "North Dakota"}, {"54", "OH", "Ohio"}, {"49", "OK", "Oklahoma"}, {"16", "OR", "Oregon"}, {"50", "PA", "Pennsylvania"}, _ Line 910: {"53", "RI", "Rhode Island"}, {"18", "SC", "South Carolina"}, {"33", "SD", "South Dakota"}, {"28", "TN", "Tennessee"}, _ Line 911: {"27", "TX", "Texas"}, {"47", "UT", "Utah"}, {"30", "VT", "Vermont"}, {"6", "VA", "Virginia"}, {"48", "WA", "Washington"}, _ Line 912: {"31", "WV", "West Virginia"}, {"24", "WI", "Wisconsin"}, {"32", "WY", "Wyoming"}} Line 913: Line 914: Return statesArray Line 915: End Function Line 916: Line 917: #End ExternalSource Line 918: Line 919: Line 920: <System.Diagnostics.DebuggerNonUserCodeAttribute()> _ Line 921: Public Sub New() Line 922: MyBase.New Line 923: Dim dependencies() As String Line 924: CType(Me,Global.System.Web.UI.Page).AppRelativeVirtualPath = "~/include/functions.aspx" Line 925: If (Global.ASP.include_functions_aspx.__initialized = false) Then Line 926: dependencies = New String(0) {} Line 927: dependencies(0) = "~/include/functions.aspx" Line 928: Global.ASP.include_functions_aspx.__fileDependencies = Me.GetWrappedFileDependencies(dependencies) Line 929: Global.ASP.include_functions_aspx.__initialized = true Line 930: End If Line 931: Me.Server.ScriptTimeout = 30000000 Line 932: End Sub Line 933: Line 934: Protected ReadOnly Property Profile() As System.Web.Profile.DefaultProfile Line 935: Get Line 936: Return CType(Me.Context.Profile,System.Web.Profile.DefaultProfile) Line 937: End Get Line 938: End Property Line 939: Line 940: Protected ReadOnly Property ApplicationInstance() As ASP.global_asax Line 941: Get Line 942: Return CType(Me.Context.ApplicationInstance,ASP.global_asax) Line 943: End Get Line 944: End Property Line 945: Line 946: <System.Diagnostics.DebuggerNonUserCodeAttribute()> _ Line 947: Private Sub __BuildControlTree(ByVal __ctrl As include_functions_aspx) Line 948: Line 949: #ExternalSource("D:\home\site\wwwroot\include\functions.aspx",1) Line 950: Me.InitializeCulture Line 951: Line 952: #End ExternalSource Line 953: End Sub Line 954: Line 955: <System.Diagnostics.DebuggerNonUserCodeAttribute()> _ Line 956: Protected Overrides Sub FrameworkInitialize() Line 957: MyBase.FrameworkInitialize Line 958: Me.__BuildControlTree(Me) Line 959: Me.AddWrappedFileDependencies(Global.ASP.include_functions_aspx.__fileDependencies) Line 960: Me.Request.ValidateInput Line 961: End Sub Line 962: Line 963: <System.Diagnostics.DebuggerNonUserCodeAttribute()> _ Line 964: Public Overrides Function GetTypeHashCode() As Integer Line 965: Return 5381 Line 966: End Function Line 967: Line 968: <System.Diagnostics.DebuggerNonUserCodeAttribute()> _ Line 969: Public Overrides Sub ProcessRequest(ByVal context As System.Web.HttpContext) Line 970: MyBase.ProcessRequest(context) Line 971: End Sub Line 972: End Class Line 973: End Namespace Line 974:   Version Information: Microsoft .NET Framework Version:2.0.50727.8964; ASP.NET Version:2.0.50727.8962 / jester
C · June 14, 2023, 10:59 a.m.
Javascript Basic
1. map & forEach method - Why 9? [,,,2].map((v,i)=> v * i).forEach((v, i) => console.log(v + i)); 1) let x = [,,,2].map((v,i)=> v * i); map : Array.map() 메서드는 콜백 함수를 이용해 각각의 요소에 호출해서 그 값을 변환할 수 있게 해준다. 즉 콜백 함수는 배열의 각 요소에 실행된다. 여기서 매개변수 v 는 처리할 현재 요소, i 는 처리할 현재 요소의 인덱스다. 첫 번째, 두 번째, 세 번째 요소는 비어있고 네 번째 요소에만 2가 들어있기 때문에 네 번째 요소의 값은 2 * 3 = 6이 된다. 따라서 결과는 [,,,6] 이다. 2) x.forEach((v, i) => console.log(v + i)); JavaScript의 forEach 메서드도 배열을 순회하는 여러 방법 중 하나다. 여기서도 마찬가지로 매개변수 v 는 처리할 현재 요소, i 는 처리할 현재 요소의 인덱스다. 첫 번째, 두 번째, 세 번째 요소는 비어있으므로 실행값이 없고 네 번째 요소에만 6이 들어있기 때문에 결과는 6 + 3 = 9 가 나오게 된다.
front-end · June 10, 2023, 7:21 a.m.
javascript
  • 1 (current)
  • 2
  • 3
  • 4
  • 5