How to block a connection from the certain site ?

CK CK 3788 
Created at  
350 0 0
Sometimes, you may need connection blocking from the link posted on the certain blog or site. In this case, you can block easilly by HTTP_REFERER.

Followings are the simple example blocking connection from foo.com posted content. But following example allows user to connect to the website directly. For instance, user can connect to http://foo.com when user put url on the browser, but in case of clicking link, the site can know where the connection comes from.

<?
  // Connection Blocking Example
  // Programmed 2008 by Kurapa Chunun Kang (kurapa@kurapa.com)

  if (ereg('foo.com', $_SERVER['HTTP_REFERER']))
  {
    ?><script language=javascript>self.location='http://xxx.com';</script><?
    exit;
  }
  .
  .
  .
?>
Tags PHP Referrer referer URL string function substr Facebook X
Comments 0
Similar posts
  1. File downloading via HTTP
    445
  2. How to extract file name from given URL ?
    442
  3. How to download a file from a certain URL to server ?
    419
  4. XMLRPC example
    760
  5. How to upload attachments such as image by metaWeblog API ?
    391
  6. How to post blog content by metaweblog API ?
    485
  7. ISO 8601 format time format string conversion
    533
  8. Posting to a Wordpress Blog Via XMLRPC Using Blogger API
    763
  9. HTML redirection in PHP
    398
  10. Get the actual filesize for a size above 2GB in Windows
    427
  11. How to convert W3C Date Time Format ?
    453
  12. How to put timeout when opening URL by fopen ?
    440
  13. foreach loop
    442
  14. Can PHP switch in strings ?
    391
  15. PHP Switch Example
    427
  16. How to send email in PHP ?
    889
  17. How to pass variables via url
    468
  18. How to declare array in PHP like C/C++
    670
  19. PHP date and time formatting
    428
  20. How to redirect browser in PHP ?
    482
  21. How to get current filename as variable ?
    768
  22. email validation, simple
    412
  23. How to ban / block IP addresses
    509
  24. for loop - simple
    449
  25. form action - detect form post
    428
  26. How to make random number ?
    517
  27. How to force cookies, disable php sessid in URL ?
    554
  28. How to check if a file exists ?
    786
  29. How to include a file with error reporting ?
    428
  30. PHP if...else... example
    445
  1. Photo thumbnail viewer implemented in javascript
    482
  2. Javascript Confirmation
    589
  3. Javascript Prompts
    448
  4. How to know browser version in javascript ?
    439
  5. How to know the browser name in Javascript ?
    639
  6. Select All, None, Invert checkbox
    504
  7. Simple RSS Reader based on javascript
    501
  8. How to find the ip address of a client machine from a web application?
    518
  9. Put Date Time on HTML
    550
  10. IFRAME Auto Resize in IE, FireFox by Javascript
    454
  11. How to elimiate the "Restore Previous Session" dialog when FireFox 2.0 starts
    407
  12. How to include Javascript from anonther ?
    409
  13. Javascript based Browser Sniffing
    430
  14. Javascript based Regular Expression Tester
    372
  15. Two useful string functions - substr & substring
    404
  16. Is there URLEncode function in Javascript ?
    390
  17. Move window
    545
  18. How to calculate page loading time ?
    358
  19. Number Of Vists
    507
  20. Add Message On Mouse Traling
    2,545
  21. Tooltip
    407
  22. Document Fader
    346
  23. Book Mark This Site
    403
  24. Icon Coupled Url
    425
  25. Button That Will Close The Browser Window
    349
  26. Button That Will Show The Page's Source
    385
  27. Add A Scrolling Status Bar Text To Your Site
    407
  28. Add This Page To Favorites
    397
  29. Code To Clear Browser History
    374
  30. Remove the spaces before begin and after end of text
    334
Recently updated
  1. Why 100% SEO Guarantees Better User Engagement and How to Achieve It in Your Service
    27
  2. Why SPF and DKIM Are Essential for Linux Email Servers?
    24
  3. How do I create animated background for Google Meet?
    19,711
  4. MaxMind GeoLite2 vs. DB-IP Lite vs. ip-api.com: Choosing the Right Free IP Geolocation Solution
    217
  5. Meet Valkey: Why Redis Changed Its License, Why Valkey is Better, and How to Use It as a Drop-in Replacement
    85
  6. How Rogue Web Scrapers Are Stealing My Content and Destroying My Server
    153
  7. Array of arguments passed to script in PHP
    85
  8. Invalid Auction Storms in Ad Tech
    93
  9. Building MRC-Compliant Instrumentation in Ad Tech: Implementation Steps and Key Challenges
    198
  10. The Two Clocks of Ad Server Architecture
    63
  11. Frequency Cap Architecture Overview
    509
  12. Collecting Proof-of-Play from 100,000 Screens
    141
  13. Vector Search in Relational Databases (RDBs): Trends & Usage Environments
    280
  14. What is RedisVL?
    105
  15. Designing a Skill Registry Architecture: Minimize Token Usage and Maximize AI Performance
    224
  16. TPU & GPU Cluster Management Tools
    232
  17. The Concept of Scaffolding in AI Agents
    221
  18. Beyond Static Pipelines: Architecting LLM Multi-Agent Systems for Autonomous Workflow Orchestration
    576
  19. AI-DLC vs. AI-SDLC: Model-Centric vs. System-Centric AI Development
    253
  20. Fine-Tuning Open-Weight LLMs: Training, Licensing, and Deploying Custom Models with Ollama
    327
  21. Inside the Next-Generation Streaming Architecture: Ultra-Low Latency, SGAI, and AI Codecs
    197
  22. Machine Learning: Training vs. Ranking
    213
  23. The Continuous Learning Machine: Designing a Loop That Actually Turns
    217
  24. The Next-Gen Low-Latency Standards: LL-HLS & MoQ
    189
  25. Designing a Data Curation System Around a Vector Database
    215
  26. Extracting Context from Live Video: The Architecture Got Simpler When We Stopped Building Features
    229
  27. The New Ad Stack Behind Live Sports Streaming: Inside SGAI, EABN, and the Standards Race to Fix Live Monetization
    649
  28. Designing MLOps Architectures to Handle Seasonal Data Drift in EV Fleet Models
    185
  29. From 15 to 40+ FPS: Accelerating PyTorch Object Detection on Automotive ECUs
    207
  30. Understanding Data Lineage
    252