Sunday, 16 June 2024

A simple dropdown navigation menu made with CSS Only

 A simple dropdown navigation menu made with CSS Only. Dropdowns are marked with a plus sign ( + )

Resize the screen to see the look if the screen is smaller then 768px

<html><head>

<meta name="viewport" content="width=device-width, initial-scale=1">

<style>

      /* CSS Document */


@import url(https://fonts.googleapis.com/css?family=Open+Sans);

@import url(https://fonts.googleapis.com/css?family=Bree+Serif);


body {

background: #212121;

font-size:22px;

line-height: 32px;

color: #ffffff;

margin: 0;

padding: 0;

word-wrap:break-word !important;

font-family: 'Open Sans', sans-serif;

}


h1 {

font-size: 60px;

text-align: center;

color: #FFF;

}


h3 {

font-size: 30px;

line-height: 34px;

text-align: center;

color: #FFF;

}


h3 a {

color: #FFF;

}


a {

color: #FFF;

}


h1 {

margin-top: 100px;

text-align:center;

font-size:60px;

line-height: 70px;

font-family: 'Bree Serif', 'serif';

}


#container {

margin: 0 auto;

max-width: 890px;

}


p {

text-align: center;

}


.toggle,

[id^=drop] {

display: none;

}


/* Giving a background-color to the nav container. */

nav { 

margin:0;

padding: 0;

background-color: #254441;

}


#logo {

display: block;

padding: 0 30px;

float: left;

font-size:20px;

line-height: 60px;

}


/* Since we'll have the "ul li" "float:left"

 * we need to add a clear after the container. */


nav:after {

content:"";

display:table;

clear:both;

}


/* Removing padding, margin and "list-style" from the "ul",

 * and adding "position:reltive" */

nav ul {

float: right;

padding:0;

margin:0;

list-style: none;

position: relative;

}

/* Positioning the navigation items inline */

nav ul li {

margin: 0px;

display:inline-block;

float: left;

background-color: #254441;

}


/* Styling the links */

nav a {

display:block;

padding:14px 20px;

color:#FFF;

font-size:17px;

text-decoration:none;

}



nav ul li ul li:hover { background: #000000; }


/* Background color change on Hover */

nav a:hover { 

background-color: #000000; 

}


/* Hide Dropdowns by Default

 * and giving it a position of absolute */

nav ul ul {

display: none;

position: absolute; 

/* has to be the same number as the "line-height" of "nav a" */

top: 60px; 

}

/* Display Dropdowns on Hover */

nav ul li:hover > ul {

display:inherit;

}

/* Fisrt Tier Dropdown */

nav ul ul li {

width:170px;

float:none;

display:list-item;

position: relative;

}


/* Second, Third and more Tiers

 * We move the 2nd and 3rd etc tier dropdowns to the left

 * by the amount of the width of the first tier.

*/

nav ul ul ul li {

position: relative;

top:-60px;

/* has to be the same number as the "width" of "nav ul ul li" */ 

left:170px; 

}


/* Change ' +' in order to change the Dropdown symbol */

li > a:after { content:  ' +'; }

li > a:only-child:after { content: ''; }



/* Media Queries

--------------------------------------------- */


@media all and (max-width : 768px) {


#logo {

display: block;

padding: 0;

width: 100%;

text-align: center;

float: none;

}


nav {

margin: 0;

}


/* Hide the navigation menu by default */

/* Also hide the  */

.toggle + a,

.menu {

display: none;

}


/* Stylinf the toggle lable */

.toggle {

display: block;

background-color: #254441;

padding:14px 20px;

color:#FFF;

font-size:17px;

text-decoration:none;

border:none;

}


.toggle:hover {

background-color: #000000;

}


/* Display Dropdown when clicked on Parent Lable */

[id^=drop]:checked + ul {

display: block;

}


/* Change menu item's width to 100% */

nav ul li {

display: block;

width: 100%;

}


nav ul ul .toggle,

nav ul ul a {

padding: 0 40px;

}


nav ul ul ul a {

padding: 0 80px;

}


nav a:hover,

  nav ul ul ul a {

background-color: #000000;

}

  

nav ul li ul li .toggle,

nav ul ul a,

  nav ul ul ul a{

padding:14px 20px;

color:#FFF;

font-size:17px; 

}

  

  

nav ul li ul li .toggle,

nav ul ul a {

background-color: #212121; 

}


/* Hide Dropdowns by Default */

nav ul ul {

float: none;

position:static;

color: #ffffff;

/* has to be the same number as the "line-height" of "nav a" */

}

/* Hide menus on hover */

nav ul ul li:hover > ul,

nav ul li:hover > ul {

display: none;

}

/* Fisrt Tier Dropdown */

nav ul ul li {

display: block;

width: 100%;

}


nav ul ul ul li {

position: static;

/* has to be the same number as the "width" of "nav ul ul li" */ 


}


}


@media all and (max-width : 330px) {


nav ul li {

display:block;

width: 94%;

}


}</style>

</head>

<body>

        <nav>

        <div id="logo">Your Logo here</div>


        <label for="drop" class="toggle">Menu</label>

        <input type="checkbox" id="drop" />

            <ul class="menu">

                <li><a href="#">Home</a></li>

                <li>

                    <!-- First Tier Drop Down -->

                    <label for="drop-1" class="toggle">WordPress +</label>

                    <a href="#">WordPress</a>

                    <input type="checkbox" id="drop-1"/>

                    <ul>

                        <li><a href="#">Themes and stuff</a></li>

                        <li><a href="#">Plugins</a></li>

                        <li><a href="#">Tutorials</a></li>

                    </ul> 


                </li>

                <li>


                <!-- First Tier Drop Down -->

                <label for="drop-2" class="toggle">Web Design +</label>

                <a href="#">Web Design</a>

                <input type="checkbox" id="drop-2"/>

                <ul>

                    <li><a href="#">Resources</a></li>

                    <li><a href="#">Links</a></li>

                    <li>

                       

                    <!-- Second Tier Drop Down -->        

                    <label for="drop-3" class="toggle">Tutorials +</label>

                    <a href="#">Tutorials</a>         

                    <input type="checkbox" id="drop-3"/>


                    <ul>

                        <li><a href="#">HTML/CSS</a></li>

                        <li><a href="#">jQuery</a></li>

                        <li><a href="#">Other</a></li>

                    </ul>

                    </li>

                </ul>

                </li>

                <li><a href="#">Graphic Design</a></li>

                <li><a href="#">Inspiration</a></li>

                <li><a href="#">Contact</a></li>

                <li><a href="#">About</a></li>

            </ul>

        </nav>



        <p> A simple dropdown navigation menu made with CSS Only. Dropdowns are marked with a plus sign ( + )</p>

        <p> Resize the screen to see the look if the screen is smaller then 768px </p>

        <nav>

        <div id="logo">Your Logo here</div>


        <label for="drop" class="toggle">Menu</label>

        <input type="checkbox" id="drop" />

            <ul class="menu">

                <li><a href="#">Home</a></li>

                <li>

                    <!-- First Tier Drop Down -->

                    <label for="drop-1" class="toggle">WordPress +</label>

                    <a href="#">WordPress</a>

                    <input type="checkbox" id="drop-1"/>

                    <ul>

                        <li><a href="#">Themes and stuff</a></li>

                        <li><a href="#">Plugins</a></li>

                        <li><a href="#">Tutorials</a></li>

                    </ul> 


                </li>

                <li>


                <!-- First Tier Drop Down -->

                <label for="drop-2" class="toggle">Web Design +</label>

                <a href="#">Web Design</a>

                <input type="checkbox" id="drop-2"/>

                <ul>

                    <li><a href="#">Resources</a></li>

                    <li><a href="#">Links</a></li>

                    <li>

                       

                    <!-- Second Tier Drop Down -->        

                    <label for="drop-3" class="toggle">Tutorials +</label>

                    <a href="#">Tutorials</a>         

                    <input type="checkbox" id="drop-3"/>


                    <ul>

                        <li><a href="#">HTML/CSS</a></li>

                        <li><a href="#">jQuery</a></li>

                        <li><a href="#">Other</a></li>

                    </ul>

                    </li>

                </ul>

                </li>

                <li><a href="#">Graphic Design</a></li>

                <li><a href="#">Inspiration</a></li>

                <li><a href="#">Contact</a></li>

                <li><a href="#">About</a></li>

            </ul>

        </nav>



        <p> A simple dropdown navigation menu made with CSS Only. Dropdowns are marked with a plus sign ( + )</p>

        <p> Resize the screen to see the look if the screen is smaller then 768px </p>

</body></html>



<px

Friday, 7 June 2024

Simple URL shortener in php

Create simple URL shortener for your own website in php.

table name : shortener

id int(11) auto_increament

email varchar 225

ip varchar 50

hash varchar 50

url text

status int(10)

view int(11) 

--------------------------------------------------------------------

 <?php

include "connect.php";

session_start();

if(isset($_SESSION['username']))

{

    $username = $_SESSION['username'];

}

else

{

//header('location:login.php');

}

?>

<?  $ip = $_SERVER['REMOTE_ADDR'];

$ip = str_replace(".","",$ip);

    $yourdomain = $_SERVER['HTTP_HOST'];

    $yourdomain = preg_replace('/^www\./' , '' , $yourdomain);

    ?>

<!DOCTYPE html>

<html class="no-js">

    <head>

        <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-4305348743992957"

     crossorigin="anonymous"></script>

        <meta charset="utf-8">

        <link rel='shortcut icon' href='adquash-logo.png' type='image/x-icon' />

<title>Free URL Shortener</title>

<meta name="description" content="Free URL Shortener is a tool to shorten a long link and create a short URL easy to share on sites, chat and emails. Track short URL traffic and manage your links.">

<meta name="viewport" content="width=device-width, initial-scale=1">

<meta name="keywords" content="ShortURL,free ShortURL,URL Shortener,free URL Shortener">

 <meta property="og:image" content="https://adquash.com/adquash-logo.png">

       <link rel="stylesheet" href="3.css">

    </head>

   <body>

  <div class="wrapper">

    <?php include("header.php");?>

    </div>

    <div class="container">

        <div class="left-panel">

            <div class="content">

<div class="topad"><?php include ("banner.php"); ?></div>

<div class="col-md-12">

    <?php

if(isset($_POST["submit"])){

$url = $_POST["url"];

$email = $_POST["email"];

$ip = $_POST["ip"];

$status =1;

if(!empty($url )){

    function generateRandomHash($length = 5) {

    $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';

    $charactersLength = strlen($characters);

    $randomString = '';

    for ($i = 0; $i < $length; $i++) {

        $randomString .= $characters[rand(0, $charactersLength - 1)];

    }

    return $randomString;

}


function hashExists($connection, $hash) {

    $sql = "SELECT COUNT(*) AS count FROM shortener WHERE hash = ?";

    $stmt = $connection->prepare($sql);

    $stmt->bind_param("s", $hash);

    $stmt->execute();

    $result = $stmt->get_result();

    $row = $result->fetch_assoc();

    return $row['count'] > 0;

}


function storeHash($connection, $email,$ip,$status,$url,$hash) {

    $sql = "INSERT INTO shortener (email,ip,status,url,hash) VALUES (?,?,?,?,?)";

    $stmt = $connection->prepare($sql);

    $stmt->bind_param("sssss", $email,$ip,$status,$url,$hash);

    return $stmt->execute();

}



do {

    $hash = generateRandomHash();

} while (hashExists($connection, $hash));


if (storeHash($connection, $email,$ip,$status,$url,$hash)) {

    //echo "Hash generated and stored: " . $hash;

} else {

    echo "Error storing hash: " . $connection->error;

}


$sqlf = mysqli_fetch_assoc(mysqli_query($connection,"SELECT * FROM shortener WHERE hash = '$hash'"));

echo '     

<style>

        #confirmation {

            display: none;

            color: green;

            margin-top: 10px;

        }

    </style>

    <input type="text" id="myInput" style="width:100%;height:50px;" value="https://adquash.com/'.$sqlf["hash"].'">

    <button style="width:100%;height:50px;background-color:blue;color:white;" onclick="copyToClipboard()">Copy</button>

    <div id="confirmation">Copied to clipboard!</div>

    

    <br><br>

Copy the short link and share it in messages, texts, posts, websites and other locations.<br><br>

<b>Your shortened URL : https://adquash.com/'. $sqlf["hash"] .' <br><br>

Your Long URL: '.$sqlf["url"].' </b><br><br>


Total of clicks of your <a target="_blank" href="https://adquash.com/'. $sqlf["hash"] .'">short URL</a><br>

Shorten another URL<br>


* Short URLs that do not have at least one click per month are disabled<br>


Share it on social networks<br>


    <script>

        function copyToClipboard() {

            var input = document.getElementById("myInput");

            input.select();

            input.setSelectionRange(0, 99999); // For mobile devices


            navigator.clipboard.writeText(input.value).then(function() {

                var confirmation = document.getElementById("confirmation");

                confirmation.style.display = "block";

                setTimeout(function() {

                    confirmation.style.display = "none";

                }, 3000);

            }, function(err) {

                console.error("Could not copy text: ", err);

            });

        }

    </script>';}

} else { echo '

 <center><h1>Create a short URL Free</h1></center> 

<div class="col-md-12">

                  <center><h1>Paste the URL to be shortened</h1></center>

                  <form action="#" method="post">

                      <div class="form-group col-md-12">paste your url :<br>

                      <input type="url" name="url" style="width:100%;height:50px;" placeholder="paste your url" required/></div>

                      <div class="form-group col-md-12">

                        Email       :<br>  <input type="email" name="email" style="width:100%;height:50px;" placeholder="Email Address" id="emailInput" onkeyup="validateEmail()" required/><span id="emailError" style="color: red;"></span>

   <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>

                            <script>

  function validateEmail() {

    const emailInput = document.getElementById("emailInput");

    const emailError = document.getElementById("emailError");

    const emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;


    if (!emailPattern.test(emailInput.value)) {

      emailError.textContent = "Invalid email format";

      document.getElementById("hideDiv").style.display = "none";

    } else {

      emailError.textContent = "";

      document.getElementById("hideDiv").style.display = "block";

    }

    

  }

</script>

                         </div>

   <div class="form-group col-md-12"> Your IP Address :<br>                     

                      <input type="text" name="ip" style="width:100%;height:50px;" value="'.$ip.'" readonly></div>

        <div class="form-group col-md-12">

                         <div id="hideDiv"> <input type="submit" name="submit" style="width:100%;height:50px;background-color:blue;color:white;font-size:30px" value="shorten url"></div></div>

                  </form> ';} ?>

                        <p><br><br>Adquash Short URL service is a free tool to shorten URLs and generate short links

URL shortener allows to create a shortened link making it easy to share<br><br>


<h1>Simple and fast URL shortener!</h1><br>

Adquash Short URL service allows to shorten long links from Instagram, Facebook, YouTube, Twitter, Linked In, WhatsApp, TikTok, blogs and sites. Just paste the long URL and click the Shorten URL button. On the next page, copy the shortened URL and share it on sites, chat and emails. After shortening the URL, check how many clicks it received.


<h1>Shorten, share and track</h1><br>

Your shortened URLs can be used in publications, documents, advertisements, blogs, forums, instant messages, and other locations. Track statistics for your business and projects by monitoring the number of hits from your URL with our click counter.

</center>

<center>

    

<br>

</div>

<div class="col-md-12">

<?php include 'bottomad.php' ; ?>

</div>

            </div></div></div>

    <div class="right-panel"><?php include ("sidebar_right.php"); ?></div>

        <div style="clear:both"></div>

    <div class="footer"><?php include("footer.php");?></div>  

       </body>

    </html>



<---------------------------------------------------------->

<?php 

include "connect.php";

$url = $_SERVER['HTTP_HOST'];

$urlf = str_replace('/','',$_SERVER['REQUEST_URI']);

$hash = str_replace($url,'',$urlf);

$sql = mysqli_fetch_assoc(mysqli_query($connection,"select * from shortener where hash='$hash'"));

if($sql["hash"] == $hash){

    $sqlup = mysqli_query($connection,"UPDATE shortener SET view = view+1 where hash='$hash'");

    echo "<iframe data-aa='479877' src='//acceptable.a-ads.com/479877' style='border:1px solid blue; padding:0; width:100%; height:90px; overflow:hidden; background-color: transparent;'></iframe><br><br>

    <p style='font-size:20px;'>SOME URL NOT WORK IN IFRAME : <a href=".$sql["url"]." style='font-size:20px;background-color:blue;color:white;text-decoration:none;padding:3px;'>OPEN WITHOUT IFRAME</a></p>

    <p style='font-size:28px;font-weight: bold;color:blue;'>Total View : ".$sql["view"]." </p><hr style=height:5px;width:100%;background-color:blue;><br>";

    echo "<iframe src=".$sql["url"]." style='border:0px; padding:0; width:100%; height:100%; overflow:hidden; background-color: transparent;'></iframe>";

    

}else{ echo "link disable or removed";}

?>



Sunday, 2 June 2024

The first character cannot be a space, dot, or dash

 The first character cannot be a space, dot, or dash in input form using jacescript.

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Input Filter</title>

</head>

<body>

    <input type="text" id="myInput" placeholder="Enter text">

    <script>document.getElementById('myInput').addEventListener('keyup', function (e) {

    let value = e.target.value;

    let filteredValue = value.replace(/[^a-zA-Z0-9 .-]/g, '');


    // Ensure the first character is not a space, dot, or dash

    if (/^[ .-]/.test(filteredValue)) {

        filteredValue = filteredValue.slice(1);

        alert('The first character cannot be a space, dot, or dash.');

    }


    // If a disallowed character was found, show an alert

    if (value !== filteredValue) {

        alert('Special characters other than spaces, dots, and dashes are not allowed.');

    }


    e.target.value = filteredValue;

});


</script>

</body>

</html>

Saturday, 1 June 2024

Hide first div and show second div after 500px scroll up

 Hide first div and show second div after 500px scroll up . Second div content reload every 20 second

first page create index.html

copy and paste given code in index.html . 

in load.php reload content . load.php reload every 20 second and content show in index.html second div.


<----- index.html start here --- >

<style>

    #first-div {

    display: none;

    max-width:300px;

    width:100%;

    overflow:hidden;border:1px solid green;margin-right:10px;

    }

    #second-div {

    display: none;

    position: fixed;

    top: 90px;

    right:0;

    max-width:300px;

    width:100%;

    z-index:999;

    float:right;overflow:hidden;border:1px solid green;margin-right:10px;

    }

  </style>

  <div id="first-div">

Your first div content here

</div>


  <div id="second-div">

Your second div content here

</div>


  <script>

    let reloadInterval;

    const firstDiv = document.getElementById('first-div');

    const secondDiv = document.getElementById('second-div');


    function startReloading() {

      if (!reloadInterval) {

        reloadInterval = setInterval(() => {

          fetch('load.php')

            .then(response => response.text())

            .then(data => {

              secondDiv.innerHTML = data;

              console.log('Loaded:', data);

            })

            .catch(error => console.error('Error:', error));

        }, 18000);

      }

    }


    function stopReloading() {

      if (reloadInterval) {

        clearInterval(reloadInterval);

        reloadInterval = null;

      }

    }


    function handleScroll() {

      if (window.scrollY > 500) {

        firstDiv.style.display = 'none';

        secondDiv.style.display = 'block';

        startReloading();

      } else {

        firstDiv.style.display = 'block';

        secondDiv.style.display = 'none';

        stopReloading();

      }

    }


    window.addEventListener('scroll', handleScroll);


    // Initial check in case the page is already scrolled down

    handleScroll();

  </script>


auto scroll 10px top to bottom every 5 second

 auto scroll 10px top to bottom every 5 second

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Auto Scroll Page</title>

    <script>

        // Function to scroll the page by 10 pixels

        function autoScroll() {

            window.scrollBy(0, 10);

        }


        // Wait for the page to load

        window.onload = function() {

            // Set interval to call autoScroll every 5000 milliseconds (5 seconds)

            setInterval(autoScroll, 5000);

        };

    </script>

</head>

<body>

    <h1>Auto Scroll Demo</h1>

    <p>Scroll down to see more content.</p>

    <div style="height: 2000px;"> <!-- This div adds enough content to make scrolling necessary -->

        <!-- Content goes here -->

    </div>

</body>

</html>



auto scroll 10px top to bottom random time 



<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Auto Scroll Page</title>
    <script>
        // Function to scroll the page by 10 pixels
        function autoScroll() {
            window.scrollBy(0, 10);
            // Call the function again with a random delay between 1 and 5 seconds
            let randomDelay = Math.random() * 4000 + 1000;
            setTimeout(autoScroll, randomDelay);
        }

        // Wait for the page to load
        window.onload = function() {
            // Start the auto scroll with an initial delay of 5 seconds
            setTimeout(autoScroll, 5000);
        };
    </script>
</head>
<body>
    <h1>Auto Scroll Demo</h1>
    <p>Scroll down to see more content.</p>
    <div style="height: 2000px;"> <!-- This div adds enough content to make scrolling necessary -->
        <!-- Content goes here -->
    </div>
</body>
</html>

Saturday, 25 May 2024

auto scroll up and down with random time

 Auto-scrolling a webpage up and down at random intervals between 5 to 10 seconds using JavaScript.

  1. getRandomInterval(min, max): This function generates a random interval between the provided minimum and maximum values (in seconds), converting it to milliseconds.
  2. scrollPage(): The main function that initiates the scrolling.
    • scrollHeight: The total scrollable height of the page minus the viewport height.
    • scrollAmount: The amount by which the page will scroll in each direction. Adjust this value as needed to control the scroll distance.
    • direction: A variable to keep track of the current scroll direction ('down' or 'up').
  3. performScroll(): This function handles the actual scrolling logic. It uses window.scrollBy with behavior: 'smooth' for smooth scrolling.
    • It alternates the direction of scrolling between down and up.
    • It sets a new timeout with a random interval between 5 and 10 seconds before the next scroll.
<-- code start -->
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Auto Scroll Example</title> </head> <body> <!-- Your page content goes here -->
Your content height should be 700px for best performance <script> // Include the JavaScript code provided above here
function getRandomInterval(min, max) {
  return Math.floor(Math.random() * (max - min + 1) + min) * 1000;
}

function scrollPage() {
  let scrollHeight = document.documentElement.scrollHeight - window.innerHeight;
  let scrollAmount = scrollHeight / 2; // Adjust the scroll amount as needed
  let direction = 'down';

  function performScroll() {
    if (direction === 'down') {
      window.scrollBy({
        top: scrollAmount,
        behavior: 'smooth'
      });
      direction = 'up';
    } else {
      window.scrollBy({
        top: -scrollAmount,
        behavior: 'smooth'
      });
      direction = 'down';
    }
    setTimeout(performScroll, getRandomInterval(5, 10));
  }

  setTimeout(performScroll, getRandomInterval(5, 10));
}

// Start the scrolling
scrollPage();

</script> </body> </html>