If you really want to disable Updates and Installations, you can block users from installing/updating themes and plugins through the dashboard. Add this quick snippet to your wp-config.php file:

define('DISALLOW_FILE_MODS',true);

It will prevent users from installing and updating themes and plugins. It will also automatically disable theme and plugin editing in the dashboard.


Disable Plugin and Theme Update and Installation

Sangwan Pankaj Reply 13:02

If you really want to disable Updates and Installations, you can block users from installing/updating themes and plugins through the dashbo...

Access to plugin and theme code is available in the WordPress dashboard. You can do one thing to protect the site from trifile to disable the both of these editors. Open your wp-config.php file and add the following constant:

define('DISALLOW_FILE_EDIT',true);

Now, when you are in the dashboard it is impossible to access the theme or plugin editor, even if you are admin.

Disable the Plugin and Theme Editor

Sangwan Pankaj Reply 12:57

Access to plugin and theme code is available in the WordPress dashboard. You can do one thing to protect the site from trifile to disable t...

In this tutorial, i will share how to send Email from XAMPP (PHP). i use XAMPP 1.8.1 version .This has been tested by me and it worked.

Lets start:-
first always make a backup before changing any code in core/configuration files.
then

Edit your php.ini in - “xampp\php\php.ini”

Before Changes:- 
---------------------------
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = localhost
; http://php.net/smtp-port
smtp_port = 25

; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = postmaster@localhost

; XAMPP IMPORTANT NOTE (1): If XAMPP is installed in a base directory with spaces (e.g. c:\program filesD:\xampp) fakemail and mailtodisk do not work correctly.
; XAMPP IMPORTANT NOTE (2): In this case please copy the sendmail or mailtodisk folder in your root folder (e.g. C:\sendmail) and use this for sendmail_path.

; XAMPP: Comment out this if you want to work with fakemail for forwarding to your mailbox (sendmail.exe in the sendmail folder)
;sendmail_path = "\"\XAMPP\sendmail\sendmail.exe\" -t"

After Changes :-
-----------------------
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = smtp.gmail.com
; http://php.net/smtp-port
smtp_port = 587

; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = yourgmailid@gmail.com

; XAMPP IMPORTANT NOTE (1): If XAMPP is installed in a base directory with spaces (e.g. c:\program filesD:\xampp) fakemail and mailtodisk do not work correctly.
; XAMPP IMPORTANT NOTE (2): In this case please copy the sendmail or mailtodisk folder in your root folder (e.g. C:\sendmail) and use this for sendmail_path.

; XAMPP: Comment out this if you want to work with fakemail for forwarding to your mailbox (sendmail.exe in the sendmail folder)
sendmail_path = "\"\XAMPP\sendmail\sendmail.exe\" -t"

now

Edit your sendmail.ini - “xampp\sendmail\sendmail.ini”

smtp_server=mail.mydomain.com or smtp_server=localhost

; smtp port (normally 25)
smtp_port=25

comment these two lines using - ;


;smtp_server=mail.mydomain.com or ;smtp_server=localhost
; smtp port (normally 25)

;smtp_port=25



and add some extra code in the bottom of your sendmail,ini:

;new config:
smtp_server=smtp.gmail.com
smtp_port=587
smtp_ssl=tls
error_logfile=error.log
pop3_server=
pop3_username=
pop3_password=
force_recipient=
hostname=
auth_username=yourgmailid@gmail.com
auth_password=your gmail password
force_sender=yourgmailid@gmail.com

NOTE: 
  1. You Need to restart xampp after saving both files.
  2. Change yourgmailid@gmail.com & your gmail password  with your own email id and password
  3. You Need to enable SMTP in your GMail to make this work and all sender will be from your email (if need).





Enable Send Email in XAMPP (localhost)

Sangwan Pankaj Reply 11:27

In this tutorial, i will share how to send Email from XAMPP (PHP). i use XAMPP 1.8.1 version .This has been tested by me and it worked. L...

Hi, in this tutorial we will discuss on current website url and current / working directory name

First you can get the name of the website by using

<?php echo $_SERVER['SERVER_NAME']; ?>
or
<?php echo $_SERVER['HTTP_HOST']; ?>

Now you can get the directory name

<?php echo dirname($_SERVER['PHP_SELF']); ?>

NOTE:
(if you are working on  multi folders and you need parent folder you can use 'dirname()'  function multi times

Example if you using 2 folders like /manage/user/ and you need parent folder only (i.e manage)

<?php echo dirname(dirname($_SERVER['PHP_SELF'])); ?>

you will get /admin result.

 )

Now the complete path

<?php echo "http://".dirname($_SERVER['SERVER_NAME']."".$_SERVER['PHP_SELF']); ?>

Result:  http://www.example.com/manage/user

and

complete the path with parent directory name

<?php echo "http://".dirname(dirname($_SERVER['SERVER_NAME']."".$_SERVER['PHP_SELF'])); ?>

Result:  http://www.example.com/manage






How to get working website path & directory name?

Sangwan Pankaj Reply 12:35

Hi, in this tutorial we will discuss on current website url and current / working directory name First you can get the name of the websit...

Put this code in functions.php file
<?php

if ( ! function_exists( 'wp_pagination' ) ) :
function wp_pagination() {
global $wp_query;

$int_val= 99999999; // need an unlikely integer

echo paginate_links( array(
'base' => str_replace( $int_val, '%#%', esc_url( get_pagenum_link( $int_val) ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $wp_query->max_num_pages
) );
}
endif;

?>

and put this code anywhere for pagination

<?php wp_pagination (); ?>

Pagination function in wordpress for posts

Jimmy Wales Reply 14:55

Put this code in functions.php file <?php if ( ! function_exists( 'wp_pagination' ) ) : function  wp_pagination () { glo...

function generateRandomString($length = 10) {
    $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
    $randomStringValue = '';
    for ($i = 0; $i < $length; $i++) {
        $randomStringValue .= $characters[rand(0, strlen($characters) - 1)];    }
    return $randomStringValue ;}
Output the random string :-
// Echo the random string.
echo generateRandomString(); 

PHP random string generator function

Jimmy Wales Reply 15:46

function generateRandomString ( $length = 10 ) { $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ...

Just keep a counter, increment it in the loop, and if it's an odd number set class to odd, if even set class to even. 
$result  = "";
$count = -1;

while ( $row = mysql_fetch_assoc( $query) ) {
  $class = $count++ % 2 === 0 ? "even" : "odd" ;
  $href  = $row["url"];
  $text  = $row["name"];
  $output .= "<li class='{$class}'><a href='foo?id={$href}'>{$name}</a></li>";
}

echo "<ul>{$result}</ul>";

Displaying database records in unordered list format

Jimmy Wales Reply 09:52

Just keep a counter, increment it in the loop, and if it's an odd number set class to odd, if even set class to even.  $result = ...

you can try this to redirect your own url when clicking browser back button


<script>
jQuery(document).ready(function($) {

      if (window.history && window.history.pushState) {

        $(window).on('popstate', function() {
          var hashLocation = location.hash;
          var hashSplit = hashLocation.split("#!/");
          var hashName = hashSplit[1];

          if (hashName !== '') {
            var hash = window.location.hash;
            if (hash === '') {
              alert('Back button was pressed.');
                window.location='www.yourweburlhere.com';
                return false;
            }
          }
        });

        window.history.pushState('forward', null, './#forward');
      }

    });
</script>

Redirect to another url when back button is clicked using javascript

Jimmy Wales Reply 17:02

you can try this to redirect your own url when clicking browser back button <script> jQuery ( document ). ready ( function ( $ ) ...

You need to test for the negation of the Regular Expressions because you want the validation to alert upon failure,

(is_valid = !/^[0-9]+$/.test(x))
Example :-

<form action="" method="POST" name="cdp_form" id="cdp_form">
<input type="text" id="phone_number" name="phone_number" placeholder="Enter your phone number" maxlength="10" onkeyup="validateForm()">
<button type="submit" name="SEND" class="btn btn-brown">Send</button>
</form>
<?php echo $successmsg; ?>
<script>
//form validation
function validateForm()
{
var x=document.forms["cdp_form"]["phone_number"].value
if (x==null || x=="")
  {
  alert("Phone number  field must be filled in");
  cdp_form.phone_number.focus();
  return false;
  }
else if (is_valid = !/^[0-9]+$/.test(x))
    {
    alert("Phone number field must have numeric characters");
    cdp_form.phone_number.focus();
    return false;
  }
}
</script>

Form validation of numeric characters

Jimmy Wales Reply 15:20

You need to test for the negation of the Regular Expressions because you want the validation to alert upon failure, (is_valid = !/^[0-9]+$...

split - Split string into array by regular expression

for Example :
Parse a Date which may b delimited with dots, hypens or slashes-

<?php
//store your date in $date variable
$date = "04-24-2014";
list($month, $day, $year) = split('[/.-]', $date);
echo "Month: $month; Day: $day; Year: $year<br />\n";
?>

2nd Example :-

<?php
//store your date in $date variable
$date = "04-24-2014";
list($month, $day, $year) = split('[/.-]', $date);

//  - convert number to month name
$monthNum  = $month;
$monthName = date('F', mktime(0, 0, 0, $monthNum, 10)); // March
echo $monthName .' '.$day .', '. $year ;
?>






Split date string in PHP

Jimmy Wales Reply 11:56

split - Split string into array by regular expression for Example : Parse a Date which may b delimited with dots, hypens or slashes- ...



This Javascript code will scroll the page bottom
$('html, body').animate({scrollTop:$(document).height()}, 'fast'); 
and change your speed as required in numerical or slow , fast. Here we use fast in example
And create jQuery function 
$(document).ready(function() {     
 $('#yourId').click(function(){
       $('html, body').animate({scrollTop:$(document).height()}, 'fast');
        return false;  });
}); 
And for body part 
Use a link to an anchor tag e.g. <div id="yourId"> or <a href="#yourId"> 
Put this code in Header part:-
(Complete Code)
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript">
 function bottomScroll() {
  $('html, body').animate({scrollTop:$(document).height()}, 'fast');
 }
 function topScroll() {
  $('html, body').animate({scrollTop:0}, 'fast');
 }
</script>
 
Put this code in Header part:-

 <a href="javascript:bottomScroll()">Bottom Scroll</a>
 <a href="javascript:topScroll()">Top Scroll</a> 
 



Scroll to the Bottom and Top of a page with jQuery

Sangwan Pankaj Reply 12:12

This Javascript code will scroll the page bottom $( 'html, body' ).animate({scrollTop:$(document).height()}, 'fast' );  ...


Multiple selection of a drop down listbox by using onChange event trigger. 
HTML CODE
<select id=p1 name=no_year onChange="show_month()"; multiple size=4><option value=Jan>January</option>
<option value=February>February</option>
<option value=March>March</option>
<option value=April>April</option>
<option value=June>June</option>
<option value=Jul>July</option>
<option value=Auguest>Auguest</option>
<option value=September>Septembr</option>
<option value=October>October</option>
<option value=November>November</option>
<option value=December>December</option>
</select>
<div id='getValue'><br><br></div>

JAVASCTIPT
<script type="text/javascript">
function show_month(){
var str='';
for (i=0;i<p1.length;i++) {
if(p1[i].selected){
str +=p1[i].value + "<br >";
}
}
document.getElementById("getValue").innerHTML=str;
return true;
}
</script>

Multiple selection of Drop down listbox onChange

Sangwan Pankaj Reply 10:18

Multiple  selection of a drop down listbox by using onChange event trigger.  HTML CODE <select id=p1 name=no_year onChange="sho...

Today's topic is :- The selected option of a drop down listbox by using onChange event trigger. The onChange event will trigger 1 JavaScript function and we will try to read the selected item by using getElementById

Option 1:-
HTML CODE
<select>
    <option value="1">pankaj</option>
    <option value="2">sangwan</option>
</select>
JAVASCTIPT
$('select').on('change', function() {
  alert( this.value ); // output of your selected value

})

Option 2:-
HTML CODE
<select id="mySelect" onchange="copy();">
<option value="">Select a person:</option>
    <option value="pankaj" >pankaj</option>
    <option value="gurinder" >gurinder</option>
    <option value="avneet" >avneet</option>
    <option value="John Smith" >John Smith</option>
</select>
//value shows in here
<div id="label"></div>

JAVASCTIPT
function copy() { document.getElementById("label").innerHTML=document.getElementById("mySelect").value

}


Option 3:-
HTML CODE

<label for="continent">Select Continent</label>
  <select id="continent" onchange="countryChange(this);">
    <option value="empty">Select a Continent</option>
    <option value="North America">North America</option>
    <option value="South America">South America</option>
    <option value="Asia">Asia</option>
    <option value="Europe">Europe</option>
  </select>
  <br/>
  <label for="country">Select a country</label>
  <select id="country">
    <option value="0">Select a country</option>

  </select>

JAVASCTIPT
<script type="text/javascript">
 //<![CDATA[
 // array of possible countries in the same order as they appear in the country selection list
 var countryLists = new Array(4)
 countryLists["empty"] = ["Select a Country"];
 countryLists["Asia"] = ["India", "China", "Japan", "Nepal"];
 countryLists["North America"] = ["Canada", "United States", "Mexico"];
 countryLists["South America"] = ["Argentina", "Chile", "Brazil"];
 countryLists["Europe"]= ["Spain", "France", "Germany", "Britain"];

 function countryChange(selectObj) {
 // get the index of the selected option
 var idx = selectObj.selectedIndex;
 // get the value of the selected option
 var which = selectObj.options[idx].value;
 // use the selected option value to retrieve the list of items from the countryLists array
 cList = countryLists[which];
 // get the country select element via its known id
 var cSelect = document.getElementById("country");
 // remove the current options from the country select
 var len=cSelect.options.length;
 while (cSelect.options.length > 0) {
 cSelect.remove(0);
 }
 var newOption;
 // create new options
 for (var i=0; i<cList.length; i++) {
 newOption = document.createElement("option");
 newOption.value = cList[i];  // assumes option string and value are the same
 newOption.text=cList[i];
 // add the new option
 try {
 cSelect.add(newOption);  // this will fail in DOM browsers but is needed for IE
 }
 catch (e) {
 cSelect.appendChild(newOption);
 }
 }
 }
//]]>

</script>



Single selection of Drop down listbox onChange

Sangwan Pankaj Reply 10:14

Today's topic is :-  The selected option of a drop down listbox by using onChange event trigger. The onChange event will trigger 1 Java...

Test Credit Card Account Numbers

While testing, use only the credit card numbers listed here. Other numbers produce an error.
Expiration Date must be a valid date in the future (use the mmyy format). for ex:- may 2018 and use cvv - 123

Test Credit Card Account Numbers

Credit Card Type
Credit Card Number
American Express
378282246310005
American Express
371449635398431
American Express Corporate
378734493671000
Australian BankCard
5610591081018250
Diners Club
30569309025904
Diners Club
38520000023237
Discover
6011111111111117
Discover
6011000990139424
JCB
3530111333300000
JCB
3566002020360505
MasterCard
5555555555554444
MasterCard
5105105105105100
Visa
4111111111111111
Visa
4012888888881881
Visa
4222222222222
Note : Even though this number has a different character count than the other test numbers, it is the correct and functional number.
Processor-specific Cards
Dankort (PBS)
76009244561
Dankort (PBS)
5019717010103742
Switch/Solo (Paymentech)
6331101999990016

Test Credit Card Account Numbers for Test Payments

Sangwan Pankaj Reply 12:58

Test Credit Card Account Numbers While testing, use only the credit card numbers listed here. Other numbers produce an error. Expirati...

<html>
<body>
<form action="<?php $_SERVER['PHP_SELF']; ?>" method="POST" enctype="multipart/form-data">
<input type="file" name="file" >
<input type="submit" name="submit" value="Upload">
</form>
</body>
</html>

<?php
$host = 'localhost';
$user = 'root';
$pw = '';
$db = 'Database name';

$con = mysql_connect($host,$user,$pw);
mysql_select_db($db, $con);

if(@$_POST['submit'])
{
    $query=null;
   
    $file = $_FILES['file'];
    $file_name = $file['name'];   
    $file_type = $file['type'];   
    $file_size = $file['size'];
    $file_path = $file['tmp_name'];   

    if($file_name!="" && ($file_type="image/jpeg"|| $file_type="image/png"|| $file_type="image/gif") && $file_size<=1048576) {
    if(move_uploaded_file($file_path,'images/'.$file_name)){
        $query = " INSERT INTO `tablename`(`id`, `name`, `image`) VALUES('','$file_name','images/$file_name')";
          $res = mysql_query("$query");
          if($res == 'true')
          {
              echo "File uploaded!";
           }
        }
      }
     }       
        echo '</br>';
        // Fetch data from database and show on front page. If you want to show in different page just copy the below code and paste on that page

        $result = mysql_query("SELECT * FROM `tablename`");       
        while ($row = mysql_fetch_array($result)) {
        echo "<img src='".$row['image']."' height='150px' width='250px'></br>";       
        }   
    ?>

Upload and fetch images from database (Mysql) in PHP

Sangwan Pankaj Reply 22:09

<html> <body> <form action=" <? php $_SERVER [ 'PHP_SELF' ]; ?> " method="POST" enctype=...

Copyright by GhostPHP. Powered by Blogger.

Search

Recent Post

Popular Posts

Follow us