Online Tuition Class For Mathematics

We provide online tuition class for cbse mathematics for class 5 to 10th.

Teacher Name : Mamta Kumari
Highest Qualification : B.COM from DU
Tuition Duration : 2 Hrs
Pricing : 500 Per Class

Note : No trial class available, Fee paid in advance for minimum 5 classes

DNSSEC – What Is It and Why Is It Important?

A brief description of how DNS works

To understand Domain Name System Security Extensions (DNSSEC), it helps to have a basic understanding of the Domain Name System (DNS).

The proper functioning of the Internet is critically dependent on the DNS . Every web page visited, every email sent, every picture retrieved from a social media: all those interactions use the DNS to translate human-friendly domain names (such as icann.org) to the IP addresses (such as 192.0.43.7 and 2001:500:88:200::7) needed by servers, routers, and other network devices to route traffic across the Internet to the proper destination.

Using the Internet on any device starts with the DNS. For example, consider when a user enters a web site name in a browser on their phone. The browser uses the stub resolver, which is part of the device’s operating system, to begin the process of translating the web site’s domain name into an Internet Protocol (IP) address. A stub resolver is a very simple DNS client that relays an application’s request for DNS data to a more complicated DNS client called a recursive resolver. Many network operators run recursive resolvers to handle DNS requests, or queries, sent by devices on their network. (Smaller operators and organizations sometimes use recursive resolvers on other networks, including recursive resolvers operated as a service for the public, such as Google Public DNS, OpenDNS, and Quad9.)

The recursive resolver tracks down, or resolves, the answer to the DNS query sent by the stub resolver. This resolution process requires the recursive resolver to send its own DNS queries, usually to multiple different authoritative name servers. The DNS data for every domain name is stored on an authoritative name server somewhere on the Internet. DNS data for a domain is called a zone. Some organizations operate their own name servers to publish their zones, but usually organizations outsource this function to third parties. There are different types of organizations that host DNS zones on behalf of others, including registrars, registries, web hosting companies, network server providers, just to name a few.

DNS by itself is not secure

DNS was designed in the 1980s when the Internet was much smaller, and security was not a primary consideration in its design. As a result, when a recursive resolver sends a query to an authoritative name server, the resolver has no way to verify the authenticity of the response. The resolver can only check that a response appears to come from the same IP address where the resolver sent the original query. But relying on the source IP address of a response is not a strong authentication mechanism, since the source IP address of a DNS response packet can be easily forged, or spoofed. As DNS was originally designed, a resolver cannot easily detect a forged response to one of its queries. An attacker can easily masquerade as the authoritative server that a resolver originally queried by spoofing a response that appears to come from that authoritative server. In other words an attacker can redirect a user to a potentially malicious site without the user realizing it.

Recursive resolvers cache the DNS data they receive from authoritative name servers to speed up the resolution process. If a stub resolver asks for DNS data that the recursive resolver has in its cache, the recursive resolver can answer immediately without the delay introduced by first querying one or more authoritative servers. This reliance on caching has a downside, however: if an attacker sends a forged DNS response that is accepted by a recursive resolver, the attacker has poisoned the cache of the recursive resolver. The resolver will then proceed to return the fraudulent DNS data to other devices that query for it.

As an example of the threat posed by a cache-poisoning attack, consider what happens when a user visits their bank’s website. The user’s device queries its configured recursive name server for the bank web site’s IP address. But an attacker could have poisoned the resolver with an IP address that points not to the legitimate site but to a web site created by the attacker. This fraudulent website impersonates the bank website and looks just the same. The unknowing user would enter their name and password, as usual. Unfortunately, the user has inadvertently provided its banking credentials to the attacker, who could then log in as that user at the legitimate bank web site to transfer funds or take other unauthorized actions.

The DNS Security Extensions (DNSSEC)

Engineers in the Internet Engineering Task Force (IETF), the organization responsible for the DNS protocol standards, long realized the lack of stronger authentication in DNS was a problem. Work on a solution began in the 1990s and the result was the DNSSEC Security Extensions (DNSSEC).

DNSSEC strengthens authentication in DNS using digital signatures based on public key cryptography. With DNSSEC, it’s not DNS queries and responses themselves that are cryptographically signed, but rather DNS data itself is signed by the owner of the data.

Every DNS zone has a public/private key pair. The zone owner uses the zone’s private key to sign DNS data in the zone and generate digital signatures over that data. As the name “private key” implies, this key material is kept secret by the zone owner. The zone’s public key, however, is published in the zone itself for anyone to retrieve. Any recursive resolver that looks up data in the zone also retrieves the zone’s public key, which it uses to validate the authenticity of the DNS data. The resolver confirms that the digital signature over the DNS data it retrieved is valid. If so, the DNS data is legitimate and is returned to the user. If the signature does not validate, the resolver assumes an attack, discards the data, and returns an error to the user.

DNSSEC adds two important features to the DNS protocol:

  • Data origin authentication allows a resolver to cryptographically verify that the data it received actually came from the zone where it believes the data originated.
  • Data integrity protection allows the resolver to know that the data hasn’t been modified in transit since it was originally signed by the zone owner with the zone’s private key.

Trusting DNSSEC keys

Every zone publishes its public key, which a recursive resolver retrieves to validate data in the zone. But how can a resolver ensure that a zone’s public key itself is authentic? A zone’s public key is signed, just like the other data in the zone. However, the public key is not signed by the zone’s private key, but by the parent zone’s private key. For example, the icann.org zone’s public key is signed by the org zone. Just as a DNS zone’s parent is responsible for publishing a child zone’s list of authoritative name servers, a zone’s parent is also responsible for vouching for the authenticity of its child zone’s public key. Every zone’s public key is signed by its parent zone, except for the root zone: it has no parent to sign its key.

The root zone’s public key is therefore an important starting point for validating DNS data. If a resolver trusts the root zone’s public key, it can trust the public keys of top-level zones signed by the root’s private key, such as the public key for the org zone. And because the resolver can trust the public key for the org zone, it can trust public keys that have been signed by their respective private key, such as the public key for icann.org. (In actual practice, the parent zone doesn’t sign the child zone’s key directly–the actual mechanism is more complicated–but the effect is the same as if the parent had signed the child’s key.)

The sequence of cryptographic keys signing other cryptographic keys is called a chain of trust. The public key at the beginning of a chain of trust is a called a trust anchor. A resolver has a list of trust anchors, which are public keys for different zones that the resolver trusts implicitly. Most resolvers are configured with just one trust anchor: the public key for the root zone. By trusting this key at the top of the DNS hierarchy, a resolve can build a chain of trust to any location in the DNS name space, as long as every zone in the path is signed.

Validating and Signing with DNSSEC

In order for the Internet to have widespread security, DNSSEC needs to be widely deployed. DNSSEC is not automatic: right now it needs to be specifically enabled by network operators at their recursive resolvers and also by domain name owners at their zone’s authoritative servers. The operators of resolvers and of authoritative servers have different incentives to turn on DNSSEC for their systems, but when they do, more users are assured of getting authenticated answers to their DNS queries. Quite simply, a user can have assurance that they are going to end up at their desired online destination.

Enabling DNSSEC validation in recursive resolvers is easy. In fact, it has been supported by nearly all common resolvers for many years. Turning it on involves changing just a few lines in the resolver’s configuration file. From that point forward, when a user asks the resolver for DNS information that comes from zones that are signed, and that data has been tampered with, the user will (purposely) get no data back. DNSSEC protects the user from getting bad data from a signed zone by detecting the attack and preventing the user from receiving the tampered data.

Signing zones with DNSSEC takes a few steps, but there are millions of zones that sign their DNS information so that users of validating resolvers can be assured of getting good data. Almost all common authoritative name server software supports signing zones, and many third-party DNS hosting providers also support DNSSEC. Usually, enabling DNSSEC for a zone with a hosting provider is quite easy: often it entails little more than clicking a check box.

For a zone owner to deploy DNSSEC by signing their zone’s data, that zone’s parent, and its parent, all the way to the root zone, also need to be signed for DNSSEC to be as effective as possible. A continuous chain of signed zones starting at the root zone allows a resolver to build a chain of trust from the root zone to validate data. For example, to effectively deploy DNSSEC in the icann.org zone, the org zone needs to be signed as well as the root zone. Fortunately, the DNS root zone has been signed since 2010, and all gTLDs and many ccTLDs are also signed.

There is one more step to complete DNSSEC deployment in a zone: the newly signed zone’s public key material needs to be sent to the zone’s parent. As described earlier, the parent zone signs the child zone’s public key, and allows a chain of trust to be built from parent to child.

Today the zone owner usually needs to communicate the zone’s public key material to the parent manually. In most cases, that communication happens through the zone owner’s registrar. Just as a zone owner interacts with its registrar to make other changes to a zone, such as the list of the zone’s authoritative name servers, the zone owner also interacts with the registrar to update the zone’s public key material. While this process is currently manual, recently developed protocols are expected to allow this process to be automated in the future.

The next steps for DNSSEC

As DNSSEC deployment grows, the DNS can become a foundation for other protocols that require a way to store data securely. New protocols have been developed that rely on DNSSEC and thus only work in zones that are signed. For example, DNS-based Authentication of Named Entities (DANE) allows the publication of Transport Layer Security (TLS) keys in zones for applications such as mail transport. DANE provides a way to verify the authenticity of public keys that does not rely on certificate authorities. New ways of adding privacy to DNS queries will be able to use DANE in the future, as well.

In 2018, ICANN changed the trust anchor for the DNS root for the first time. Many lessons were learned about DNSSEC during that process. Furthermore, many resolver operators became more aware of DNSSEC and turned on validation, and the world got to more clearly see how the entire DNSSEC system worked. In the coming years, ICANN hopes to see greater adoption of DNSSEC, both by resolver operators and zone owners. This would mean that more users everywhere could benefit from DNSSEC’s strong cryptographic assurance that they are getting authentic DNS answers to their queries.

Soa Technology

Android webview example in android studio

Layout xml file example

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#0099cc"
    tools:context=".FullscreenActivity">

    <!-- The primary full-screen view. This can be replaced with whatever view
         is needed to present your content, e.g. VideoView, SurfaceView,
         TextureView, etc. -->
    <WebView
        android:id="@+id/webview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        />



</FrameLayout>

Activity java file example

package com.aditya.laughingadda;

import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;

import android.Manifest;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.webkit.ValueCallback;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Toast;

/**
 * An example full-screen activity that shows and hides the system UI (i.e.
 * status bar and navigation/system bar) with user interaction.
 */
public class FullscreenActivity extends AppCompatActivity {
    /**
     * Whether or not the system UI should be auto-hidden after
     * {@link #AUTO_HIDE_DELAY_MILLIS} milliseconds.
     */
    private static final boolean AUTO_HIDE = true;

    /**
     * If {@link #AUTO_HIDE} is set, the number of milliseconds to wait after
     * user interaction before hiding the system UI.
     */
    private static final int AUTO_HIDE_DELAY_MILLIS = 3000;

    /**
     * Some older devices needs a small delay between UI widget updates
     * and a change of the status and navigation bar.
     */
    private static final int UI_ANIMATION_DELAY = 300;

    private View mContentView;
    private View mControlsView;
    private boolean mVisible;
    WebView myWebView;
    private int mReturnCode;
    private int mResultCode;
    private Intent mResultIntent;
    private boolean mUploadFileOnLoad = false;
    private Uri mCapturedImageURI = null;
    private ValueCallback<Uri[]> mFilePathCallback;
    private String mCameraPhotoPath;
    private static final int INPUT_FILE_REQUEST_CODE = 1;


    private ValueCallback<Uri> mUploadMessage;
    public ValueCallback<Uri[]> uploadMessage;
    public static final int REQUEST_SELECT_FILE = 100;
    private final static int FILECHOOSER_RESULTCODE = 1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_fullscreen);
         myWebView = (WebView) findViewById(R.id.webview);

        WebSettings webSettings = myWebView.getSettings();
        webSettings.setJavaScriptEnabled(true);
        webSettings.setUseWideViewPort(true);
        webSettings.setLoadWithOverviewMode(true);
        webSettings.setAllowFileAccess(true);
        webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
        webSettings.setBuiltInZoomControls(true);
        webSettings.setPluginState(WebSettings.PluginState.ON);
        webSettings.setSupportZoom(true);
        webSettings.setAllowContentAccess(true);
        final Activity activity = this;
        myWebView.loadUrl("http://laughingadda.com");
        myWebView.setWebViewClient(new MyWebViewClient(){
            public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
                Toast.makeText(activity, description, Toast.LENGTH_SHORT).show();
            }
        });
        String permission = Manifest.permission.CAMERA;
        int grant = ContextCompat.checkSelfPermission(this, permission);
        if (grant != PackageManager.PERMISSION_GRANTED) {
            String[] permission_list = new String[1];
            permission_list[0] = permission;
            ActivityCompat.requestPermissions(this, permission_list, 1);
        }

        myWebView.setWebChromeClient(new WebChromeClient()
        {
            // For 3.0+ Devices (Start)
            // onActivityResult attached before constructor
            protected void openFileChooser(ValueCallback uploadMsg, String acceptType)
            {
                mUploadMessage = uploadMsg;
                Intent i = new Intent(Intent.ACTION_GET_CONTENT);
                i.addCategory(Intent.CATEGORY_OPENABLE);
                i.setType("image/*");
                startActivityForResult(Intent.createChooser(i, "File Browser"), FILECHOOSER_RESULTCODE);
            }


            // For Lollipop 5.0+ Devices
            @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
            public boolean onShowFileChooser(WebView mWebView, ValueCallback<Uri[]> filePathCallback, WebChromeClient.FileChooserParams fileChooserParams)
            {
                if (uploadMessage != null) {
                    uploadMessage.onReceiveValue(null);
                    uploadMessage = null;
                }

                uploadMessage = filePathCallback;

                Intent intent = fileChooserParams.createIntent();
                try
                {
                    startActivityForResult(intent, REQUEST_SELECT_FILE);
                } catch (ActivityNotFoundException e)
                {
                    uploadMessage = null;
                    Toast.makeText(FullscreenActivity.this.getApplicationContext(), "Cannot Open File Chooser", Toast.LENGTH_LONG).show();
                    return false;
                }
                return true;
            }

            //For Android 4.1 only
            protected void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture)
            {
                mUploadMessage = uploadMsg;
                Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
                intent.addCategory(Intent.CATEGORY_OPENABLE);
                intent.setType("image/*");
                startActivityForResult(Intent.createChooser(intent, "File Browser"), FILECHOOSER_RESULTCODE);
            }

            protected void openFileChooser(ValueCallback<Uri> uploadMsg)
            {
                mUploadMessage = uploadMsg;
                Intent i = new Intent(Intent.ACTION_GET_CONTENT);
                i.addCategory(Intent.CATEGORY_OPENABLE);
                i.setType("image/*");
                startActivityForResult(Intent.createChooser(i, "File Chooser"), FILECHOOSER_RESULTCODE);
            }
        });



    }
    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent intent)
    {
        if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
        {
            if (requestCode == REQUEST_SELECT_FILE)
            {
                if (uploadMessage == null)
                    return;
                uploadMessage.onReceiveValue(WebChromeClient.FileChooserParams.parseResult(resultCode, intent));
                uploadMessage = null;
            }
        }
        else if (requestCode == FILECHOOSER_RESULTCODE)
        {
            if (null == mUploadMessage)
                return;
            // Use MainActivity.RESULT_OK if you're implementing WebView inside Fragment
            // Use RESULT_OK only if you're implementing WebView inside an Activity
            Uri result = intent == null || resultCode != FullscreenActivity.RESULT_OK ? null : intent.getData();
            mUploadMessage.onReceiveValue(result);
            mUploadMessage = null;
        }
        else
            Toast.makeText(FullscreenActivity.this.getApplicationContext(), "Failed to Upload Image", Toast.LENGTH_LONG).show();
    }

       // mControlsView = findViewById(R.id.fullscreen_content_controls);
        //mContentView = findViewById(R.id.fullscreen_content);


        // Set up the user interaction to manually show or hide the system UI.


        // Upon interacting with UI controls, delay any scheduled hide()
        // operations to prevent the jarring behavior of controls going away
        // while interacting with the UI.
        //findViewById(R.id.dummy_button).setOnTouchListener(mDelayHideTouchListener);

    private class MyWebViewClient extends WebViewClient {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            if (Uri.parse(url).getHost().equals("laughingadda.com")) {
                // Designate Urls that you want to load in WebView still.
                return false;
            }

            // Otherwise, give the default behavior (open in browser)
            Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
            startActivity(intent);
            return true;
        }
        @Override
        public void onPageFinished(WebView view, String url) {
            if(mUploadFileOnLoad)
            {
                myWebView.loadUrl("javascript:document.getElementById('postImage').click()");
            }
        }
    }


}

Android Manifest file example

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.aditya.laughingadda">
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />



    <application
        android:usesCleartextTraffic="true"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity
            android:name=".FullscreenActivity"
            android:configChanges="orientation|keyboardHidden|screenSize"
            android:label="@string/app_name"
            android:theme="@style/FullscreenTheme">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

Download LaughingAdda Webview Application

ITR form and Description

ITR 1
For Individuals being a Resident (other than Not Ordinarily Resident) having Total Income upto Rs.50 lakhs, having Income from Salaries, One House Property, Other Sources (Interest etc.), and Agricultural Income upto Rs.5 thousand(Not for an Individual who is either Director in a company or has invested in Unlisted Equity Shares)
ITR 2
For Individuals and HUFs not having income from profits and gains of business or profession
ITR 3
For individuals and HUFs having income from profits and gains of business or profession
ITR 4
For Individuals, HUFs and Firms (other than LLP) being a Resident having Total Income upto Rs.50 lakhs and having income from Business and Profession which is computed under sections 44AD, 44ADA or 44AE
(Not for an Individual who is either Director in a company or has invested in Unlisted Equity Shares)
ITR 5
For persons other than:-
(i) Individual,
(ii) HUF,
(iii) Company and
(iv) Person filing Form ITR-7
ITR 6
For Companies other than companies claiming exemption under section 11
ITR 7
For persons including companies required to furnish return under sections 139(4A) or 139(4B) or 139(4C) or 139(4D)

how to create react native app in windows

set up your development environment on Windows using React Native framework and Android Studio to build Android Apps

the following tools to set up my development environment:

  • Windows
  • Visual Studio Code
  • Android Studio
  • Built-in emulator in Android Studio
  • Node Package Manager (NPM)
  • Node.js (Version 8 or newer)
  • React Native command line interface (React Native CLI)
  • Java Development Kit (JDK 8 or newer)

Step 1: Install Visual Studio Code

Download and install the latest version of Visual Studio Code for Windows from https://code.visualstudio.com/

Step 2: Install Android Studio

  • Download and install the latest version of Android Studio for Windows from https://developer.android.com/studio/
  • Android Studio installs the latest Android SDK by default. React Native requires Android 6.0 (Marshmallow) SDK or higher. I decided to use Android 7.1.1 (Nougat). Feel free to use the latest SDK.
  • Make sure you have the following SDK tools installed:
Soa Technology

Important: You will need the Intel x86 Emulator Accelerator (HAXM installer) to run the emulator on Windows. For more information, please refer to the following link: https://github.com/intel/haxm/wiki/Installation-Instructions-on-Windows

Note: You need to enable Intel Virtualization Technology by changing a BIOS setting. Please look at the following link to see how that is done:

  • Configure the ANDROID_HOME environment variable. Open the System pane under System and Security in the Windows Control Panel, then click on Change settings. Open the Advanced tab and click on Environment Variables. Click on New to create a new ANDROID_HOME user variable that points to the path to your Android SDK:
Figure 3: PATH variable for Android
  • Finally, add Android Debug Bridge (ADB) to the PATH environment variable. This will help you know which devices are connected or which emulators are currently running. Install location of ADB: C:\Users\apatil\AppData\Local\Android\Sdk\platform-tools\adb.exe

Step 3: Install Node

  • Download and install the latest version of Node.js from https://nodejs.org/en/Note: Npm is installed with Node.js.

Note: Make sure you add NPM to the PATH environment variable.

  • Once npm is installed, install React Native CLI by running the following command from the Windows prompt command line or Integrated Terminal in Visual Studio Code. Note: Integrated Terminal can be found under View →Integrated Terminal
npm install -g react-native-cli

Step 4: Using embedded JDK

Android Studio comes with an embedded JDK which is recommended. Make sure you check the following option under File → Other Settings → Default Project Structure in Android Studio:

Soa Technology

Step 5: Creating a new React Native application

Finally, lets create our first React Native application by running the following command in your workspace location

react-native init SampleReactNativeProject

This creates the following project directory structure when you open the project in Visual Studio Code.

Soa Technology

Step 6: Building for Android

  • Before we go ahead and run the app, open up the “android” directory in our project in Android Studio and create an “assets” directory under app/src/main.
Soa Technology

To simplify the build and install process, in package.json, add the following script under “scripts”:

"android-windows": "react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res && react-native run-android"

Now run the following command to install the app and see it running on the emulator. This runs the script above which we set up in package.json.

npm run android-windows

This starts up a Metro Bundler instance in a new command prompt instance and installs the app on the emulator as shown below:

Insert data into mysql table in php using mysqli method

Create File first.php using form

<style>
    input{
        display: block;
    }
    </style>
    <form method="post" action="second.php" enctype="multipart/form-data">
<input type="text" name="user_name">
<input type="password" name="user_password">

Male <input type="radio" name="gender" value="male" checked>
Female <input type="radio" name="gender" value="female">

<input type="checkbox" name="car" value="Maruti"> Car 
<input type="checkbox" name="house" value="Narela"> House 
<input type="checkbox" name="bike" value="Bajaj"> Bike 

<input type="file" name="image[]" multiple>

<input type="submit" value="Click" name="click">
</form>

Create file second.php to insert data into table

this example show only two fields, you can add more field in php code to insert.

<?php
$host="localhost";
$user="root";
$password="";
$database="pankaj";


$link= mysqli_connect($host, $user, $password, $database);
if(!$link)
{
    echo "Not Connected".mysqli_error($link);
    die();
}

$user_name=$_POST['user_name'];
$user_Password=$_POST['user_password'];

$cmd="insert into user  set user_name='$user_name', user_password='$user_Password'";
if(mysqli_query($link, $cmd))
{
 echo "Success";   
}
else
{
    echo "User Already Exists";//mysqli_error($link);
}




?>


Multiple File Upload Example In PHP

1. Create file first.php

<style>
    input{
        display: block;
    }
    </style>
    <form method="post" action="second.php" enctype="multipart/form-data">
<input type="text" name="user_name">
<input type="password" name="user_password">

Male <input type="radio" name="gender" value="male" checked>
Female <input type="radio" name="gender" value="female">

<input type="checkbox" name="car" value="Maruti"> Car 
<input type="checkbox" name="house" value="Narela"> House 
<input type="checkbox" name="bike" value="Bajaj"> Bike 

<input type="file" name="image[]" multiple>

<input type="submit" value="Click" name="click">
</form>

2. Create file second.php

<?php

$i=0;
foreach($_FILES['image']['name'] as $file => $name)
{
  echo $_FILES['image']["tmp_name"][$file]."<br>";
  echo $_FILES['image']["name"][$file]."<br>";
  echo $_FILES['image']["type"][$file]."<br>";
  echo $_FILES['image']["size"][$file]."<br>";
   
   $ext=pathinfo(basename($_FILES["image"]["name"][$file]), PATHINFO_EXTENSION);

$target_file="./profile".$i.".".$ext;
$i++;
   
   move_uploaded_file($_FILES["image"]["tmp_name"][$file], $target_file);
}

echo "total file ".count($_FILES['image']['name']);
?>

Below code show example for check file size, file extension, file type for uploading valid file

<?php
print_r($_POST);
echo "<br>";
print_r($_FILES);

echo "<br>File Name : ".$_FILES['image']['name']."<br>";
echo "File Type : ".$_FILES['image']['type']."<br>";
echo "File Temp Name  : ".$_FILES['image']['tmp_name']."<br>";
echo "File Size : in bytes ".$_FILES['image']['size']."<br>";
$file=$_FILES['image']['size'] / 1024;
echo "File Size : in KB ".number_format($file, 2)."<br>";
$file=$file / 1024;

echo "File Size : in MB ".number_format($file, 2)."<br>";
echo "File Error : ".$_FILES['image']['error']."<br>";


$ext=pathinfo(basename($_FILES["image"]["name"]), PATHINFO_EXTENSION);
$filename=time();
$target_file="./".$filename.".".$ext;

move_uploaded_file($_FILES["image"]["tmp_name"], $target_file);

?>

Command Line Example In C

prog1.c

void main(int argc,char *argv[])
{int i;
printf("%d",argc);
for (i=1;i<argc;i++)
printf("%s\n",argv[i]);
}
c:\prog1.exe 1  4 5 6 6 56 7

showfile.c

#include<process.h>
#include<stdio.h>
void main(int argc, char *argv[])
{ char ch;
FILE *src;
src=fopen(argv[1],"r");
do{
ch=fgetc(src);
if(ch==EOF)
break;
putchar(ch);
}while(1);
}
c:\showfile.exe filename.txt

list.c

#include<process.h>
void main(int argc, char *argv[])
{ char com[20];
if(argc==1)
system("dir");
else
if(argc==2)
{
strcpy(com,"dir ");
strcat(com,argv[1]);
system(com );
}
}
c:\list.exe foldername

copyfile.c

#include<process.h>
#include<stdio.h>
void main(int argc, char *argv[])
{ char ch;
FILE *src,*trgt;
src=fopen(argv[1],"r");
trgt=fopen(argv[2],"w");
do{
ch=fgetc(src);
if(ch==EOF)
break;
fputc(ch,trgt);
}while(1);
}
c:\filecopy.exe file1.txt newfile.txt

Circular Queue Example C

#include<stdio.h>
#include<process.h>
#include<stdlib.h>
#include<math.h>
#define MAX 3
typedef int itemtype;
typedef struct queue* qptr;
struct queue
{
itemtype data[MAX];
int front,rear;
};
void init(qptr q);
void add(qptr q,itemtype x);
void removeq(qptr q);
int full(qptr q);
int empty(qptr q);
int count(qptr q);

void init(qptr q)
{
q->front=0;
q->rear=-1;
}

void add(qptr q,itemtype x)
{
if(!full(q))
{
q->rear=(q->rear+1)%MAX;
q->data[q->rear]=x;
}
else
{
printf("\nqueue is full...\n");
}
}

void removeq(qptr q)
{
if(!empty(q))
{
	printf("\n%d removed \n",q->data[q->front]);
	q->data[q->front]=-1;
	printf("\n%d after remove \n",q->data[q->front]);
	q->front=(q->front+1)%MAX;
}
else
{
printf("\nqueue is empty\n");
}
}

int full(qptr q)
{
if(count(q)==MAX)
return 1;
else
return 0;
}

int empty(qptr q)
{
return (!count(q));
}

int count(qptr q)
{
	if((q->front>q->rear)&&((q->data[q->rear]!=-1)&&(q->rear!=-1)))
		return (MAX-((q->front-q->rear)-1));
	else if((q->front<=q->rear)&&(q->data[q->rear]!=-1))
		return abs(((q->front-q->rear)-1));
	else
		return 0;
}



int main()
{
qptr q;
int ch,x;
char choice;
q=(qptr)malloc(sizeof(struct queue));
init(q);
do
{
printf("\n || MENU || \n");
printf("\n 1. add in cqueue");                 
printf("\n 2. remove from cqueue");
printf("\n 3. count"); 
printf("\n\n Enter your choice (1-3) : ");
scanf("%d",&ch);
if(ch==1)
{
printf("\n Enter value in queue : ");
scanf("%d",&x);
add(q,x);
}
else if(ch==2)
{
removeq(q);
}
else if(ch==3)
{
printf("\n count = %d \n",count(q));
}
else
{
printf("\n Invalid choice...\n");
}
	fflush(stdin);
	printf("\n want to continue (y/n) : ");
	scanf("%c",&choice);
}while(choice=='y'||choice=='Y');
system("pause");
}

Input Output Stream In CPP

#include<iostream>
#include<conio.h>
#include<fstream>
using namespace std;
class student
{
int roll;
char name[20];
public:
void addrecord()
{
fstream file;
file.open("student.dat",ios::app | ios::out | ios::binary);
if(!file)
{
cout<<"not found";
}
cout<<"enter rolll : ";
cin>>roll;
fflush(stdin);
cout<<"enter name :";
cin.getline(name,20);
file.write((char*)this,sizeof(student));
file.close();
}
void writerecord()
{
     fstream file;
file.open("student.dat",ios::app | ios::out | ios::binary);
if(!file)
{
cout<<"not found";
}
cout<<"enter rolll : ";
cin>>roll;
fflush(stdin);
cout<<"enter name :";
cin.getline(name,20);
file.write((char*)this,sizeof(student));
file.close();
}
     
void showrecord()
{
fstream file;
file.open("student.dat",ios::in | ios::binary);
if(!file)
{
cout<<"not found";
}
else
while(1)
{
file.read((char*)this,sizeof(student));
if(file.eof())

break;
cout<<this->roll<<this->name<<endl;
} 

file.close();
}
};
int main()
{
student s1;

s1.writerecord();
s1.showrecord();
getch();
}