Nowdays, mostly all of the site/blog owners are frustrated because of spammers, they put spam/phishing links in comments and contact forms also, whenver our geneuine users using site they may face problem because of this.
Now let's see how we can implement this,
assets/images/captcha.php
<?php session_start(); if(isset($_SESSION['captcha'])) { unset($_SESSION['captcha']); //removing if captcha already set for session } $string1 = "abcdefghijklmnpqrstuvwxyz"; $string2 = "123456789"; $string = $string1.$string2; //From these 2 random string will be generated $string = str_shuffle($string); $rand = substr($string,0,5); $_SESSION['captcha']=$rand; //setting new captcha string /* Create an image in php */ $myimg = imagecreate(100, 30); $background = imagecolorallocate($myimg, 199, 144, 225); // background color $text_colour = imagecolorallocate ($myimg, 245, 245, 245); // text color imagestring($myimg,12,25,8,$_SESSION['captcha'],$text_colour); // add captcha code in image header ("Content-type: image/png"); imagepng ($myimg); // displayed image createde imagedestroy($myimg); // remove allocated memory. ?>
Now on the login page just use one image tag with src as the path of captcha.php,
and check the if captcha is valid using the session.
Once source code is downloaded. Now visit your website's CPanel. You can access your cpanel from your hosting provider's site or you can directly access using cpanel.yoursite.com or yoursite.com/cpanel .
Once you accessed your CPanel we will be moving to upload our files on CPanel Account .
To upload click on File Manager and Go to Public_html folder and create desired folder.
Suppose you want to add your software at example.com/url then create a folder url inside your public_html folder.
Now upload the .zip file we downloaded from above link. Now we have to extract that file. After extraction, you will get a folder with the same name as our zip file name. Now we can securely delete that zip file. Now move the content from our EasyURLs-master . folder to our link folder.
tha's it. we completed our first task to upload required files to the server.
To create database click on MySQL Databases. see image below. option 1 to be selected.
Once you click you will be redirected to page where it will ask you the name of database. You have to enter database name you want to use. Keep Good & understandable database name & click on Create Database.
Once the database is created. we have to create a user to access the database we just created. To create users just scroll down. You will get the option to Add New User. Create a username & you can use a password generator to generate passwords. Keep all this data safe and secure. we need all this data while setting up your app.
The last step & important step is to authorize user to use our database. Just scroll more you will find Add User to Database option.
Now select the user and appropriate database and click on Add button. Now you will be redirected to another page. Where you are required to select the rights to users on the database. simply select ALL PRIVILEGES.
Now click on Make Changes . Done, we have done database part too.
Note : If needed you can install free ssl certificate, to install ssl please read this article
Now visit yoursite.com/link or yoursite.com on which path you uploaded files in last step, it will redirect you to yoursite.com/install.php
In form below enter the following details, to install application.
Host : If you are installing on same server use localhost, if you are using external database make please use IP Address and port 3306 e.g. 1.1.1.1:3306, You have to start access in MySQL remote database else it will not work
Database username : enter username generated in last step
Database Password : enter db user's password
Database Name : now database name
Important : If you see error, please check your database credentials, if those are correct and you are still facing issue then please give database access to user Read more
If you don't see any errors, then you completed setup correctly, In next step enter
Username : this is just short name for login e.g. admin,peter etc.
Email : enter valid email id, After new update you will be able to reset your password with this mail, So enter correct mail id.
Password : Use strong password, keep it secure.
Click on Complete Installation, Now it will show that installation has been completed. it will take you automatically to login page.
note
If you face any issue during installation & unable to complete installation, Please delete config.php file and start process again, also create database again
After login click Manage URLS on navigation bar now you can see all the links created by you as we are creating our first link click on add new link enter long URL after that enter short URL it will show you availability, if the URL is available click on add it will create short url.
To copy short url, Right click on short code and click Copy Link Address
You can download excel file of all the urls generated, to download visit Manage Links --> All Links --> Download Excel, it will download .xls file, if you see any warning please ignore the excel file is safe to use.
After login click Manage Users on navigation bar now you can see all the Users in system.Click on Add New Link enter Email,Username,Password, if the Email and Username is available click on add it will add new user in System.
Just click on Reset button next to email of user and it will generate temporary password for the user, you can share with user and after that they can change their password from their profile.
You can download excel file of all the users generated, to download visit Manage Users --> All Users --> Download Excel, it will download .xls file, if you see any warning please ignore the excel file is safe to use.
After login click API on navigation bar now you can see all the API KEYS in system.Click on Add New API KEY then enter KEY NAME, please note that key will be auto-generated, after that click on Add New API Key it will add new API KEY in System.
To delete URL API --> All KEYS, Click Delete button next to any KEY to delete that API KEY, Once key is deleted all the applications using that key will stop working.
// base url your_domain.com/api.php Request type : `GET` // following parameters are required `API_KEY` : Enter key you generated in last step `TYPE` : `LINKS`
// base url your_domain.com/api.php Request type : `GET` // following parameters are required `API_KEY` : Enter key you generated in last step `TYPE` : `VIEW` `LINK_ID` :int LINK_ID e.g.1
If you want specific short link for given long_url, please pass params as follow
Request
// base url your_domain.com/api.php Request type : `GET` // following parameters are required `API_KEY` : Enter key you generated in last step `TYPE` : `ADD` `SHORT_URL` : short_url you want to set,donot use domain, use only code e.f. xyz `LONG_URL` : LONG_URL is url where you want to redirect your short url
// base url your_domain.com/api.php Request type : `GET` // following parameters are required `API_KEY` : Enter key you generated in last step `TYPE` : `ADD` `LONG_URL` : LONG_URL is url where you want to redirect your short url
// base url your_domain.com/api.php Request type : `GET` // following parameters are required `API_KEY` : Enter key you generated in last step `TYPE` : `DELETE` `LINK_ID` :int LINK_ID e.g.1
// base url your_domain.com/api.php Request type : `GET` // following parameters are required `API_KEY` : Enter key you generated in last step `TYPE` : `USERS`
// base url your_domain.com/api.php Request type : `GET` // following parameters are required `API_KEY` : Enter key you generated in last step `TYPE` : `VIEW` `USER_ID` :int USER_ID e.g.1
// base url your_domain.com/api.php Request type : `GET` // following parameters are required `API_KEY` : Enter key you generated in last step `TYPE` : `ADD` `EMAIL` : users email `USERNAME` : username for login `PASSWORD` : send non-encrypted password, it will be automatically encrypted.
You will get following response
response.json
User added[ { "USER_ID":"14", "USERNAME":"test", "EMAIL":"in@demo.com" } ]
// base url your_domain.com/api.php Request type : `GET` // following parameters are required `API_KEY` : Enter key you generated in last step `TYPE` : `DELETE` `USER_ID` :int USER_ID e.g.1
Visit any language file you want, please note we're using iso language code for file name, for example, file name for Hindi language will be hi.php, After making changes please create pull request.
To add new language please find correct ISO code of language you are adding and create file with ISO_LANGUAGE_CODE.PHP, for example name for Hindi language file will be hi.php, Now copy the text from sample.php and paste it in file you just created and replace array values as required.
language.php
"Language"=>"Language Name you want to show", .. ... // Now complete all remaining fields
After that open index.php and add new array key and value for language
Are you looking for status page for your site/sites? Many times we need to check if our site is working properly or not, So I developed this tool, You can easily host it on GitHub Pages and by just making few changes you can create status page for your website & as it is hosted on GitHub pages, it is completely free to use.
See Live App Preview
Now at the place of site_name you have to enter your site Title & in site_url enter exact URL of your site with http or https properly.
Make sure you haven't kept any previous site name, just remove all of them & add yours
Now create file in incidents/ folder with site name for example if your site name is Example Site in main.js then your file name will be Example Site.json, Do not remove spaces or anything , use exact site name from main.js & keep file in incidents/ folder .
To report incident open your site file from incidents/ folder, & copy content below there
incidents/site_name.json
[ { "incident_name":"incident_name at time", "description":"description" }, { "incident_name":"incident_name 2 at time", "description":"description 2" } ]
Make changes according to your requirements, that's it
Done ! Once GitHub Build pages your site status page will be Live.
We have tried our best to keep the code bug free, users are requested to confirm information with their sites before using the information provided. The author reserves the right not to be responsible for the topicality, correctness, completeness or quality of the information provided. Liability claims regarding damage caused by the use of any information provided, including any kind of information which is incomplete or incorrect, will therefore be rejected.
Statement >
Suppose you have an array of numbers and you have to create a function that will accept 2 parameters an array and rank, you have to print the highest rank number from the array to know more read the example below.
Example :
Example Input
Input arr=array(10,25,55,66,48,33,22,13,98,95,96) rank=2 Then Output should be 2nd highest element of array i.e.96
Example 2>
Example Input 2
Input arr=array(10,25,55,66,48,33,22,13,98,95,96) rank=3 Then Output should be 3rd highest element of array i.e.96
Important : First, try your own logic & then see answers, if you think you have better logic than the article please drop a comment, we'll publish your code
Logic >
Basically, we have to find the nth highest element from the given array, We will use a simple method, Just sort the array in descending order and call print n-1th element (as array starts from index 0)
If you get similar question with another logic like find nth smallest element from the given array, then just sort array in ascending order
import java.util.Collections; import java.util.Arrays; public class HelloWorld{ public static void main(String []args){ int arr[]={33,3,4,5}; int pos=2; Arrays.sort(arr, Collections.reverseOrder()); System.out.println(arr[pos-1]); } }
First-line represents the number of rows as M.
Second-line represents the number of columns as N.
The third line contains matrix elements of 1st row and so on.
output
Output 1 2 2 9 3 -1 4 2
Program >
Transponse.java
// DriverMain.java import java.util.*; public class DriverMain { public static void main(String[] args) { Scanner s = new Scanner(System.in); int r = s.nextInt(); int c = s.nextInt(); int first[][] = new int[r][c]; for (int i = 0; i < r; i++){ for (int j = 0; j < c; j++){ first[i][j] = s.nextInt(); }} for(int i = 0; i < c; i++) { for(int j = 0; j < r; j++) { System.out.print(first[j][i]+" "); } System.out.println(" "); } } }
Que > Write a program to read Name and age of person from file named โfile.txt' and print if person is eligible for voting or not.
file.txt
Your Name,24
Program.py
defcheckAge(name,age): if(int(age)>18): print(name+" is eligible for voting") else: print(name+" is not eligible for voting") f=open("file.txt") content=f.read() data=content.split(",") checkAge(data[0],data[1])
import numpy as np import matplotlib.pyplot as plt x = np.arange(1,11,1) y = np.arange(10,0,-1) # plot our list in X,Y coordinates plt.scatter(x, y) plt.show()