Google help on software/programming And Windows Tricks

helponsoftware

Friday, 5 June 2015

Exclude any field from select query


CREATE TEMPORARY TABLE IF NOT EXISTS table2 AS (SELECT * FROM table1);

ALTER TABLE table2 DROP field_name;
SELECT * FROM table2;
DROP TABLE table2;

Tuesday, 26 May 2015

Remove inline style in attachments

add_filter('wp_get_attachment_link', 'remove_img_width_height', 10, 1);

function remove_img_width_height($html) {
    $html = preg_replace( '/(width|height)=\"\d*\"\s/', "", $html );
    return $html;
}

Tuesday, 28 April 2015

calculate the maximum length of palindrome by given any array of names or string

<?php
   function PalindromeLengthPuzzle($input1)
    {
$polin_array =array();
foreach ($input1 as $key => $value) {
  $res[]= substr($value,0,1);
}
print_r($res);
for($c=0;$c<=1000;$c++):
shuffle($res);

$result= implode('',$res);

if($result==strrev($result)){
 $polin_array[]=$result;   
}

endfor;
$polin_array=array_unique($polin_array);
print_r($polin_array);

foreach ($polin_array as $key => $value) {
    $val =strlen($value);
}
echo $val;
}

echo PalindromeLengthPuzzle(array('Bharti', 'Bharat','Brijesh','Bhavna','Anjit','Chand','Aushil'));
?>

Monday, 27 April 2015

Wordpress Login by Any page

<?php
include('../impact windows/wp-load.php');
?>
<form method="post" action="http://localhost/anjit/impact%20windows/wp-login.php">
<input type="text" name="log">
<input type="password" name="pwd">
<input type="submit" name="sumit">
<input type="hidden" name="redirect_to" value="http://localhost/anjit/impact%20windows/wp-admin/edit.php?post_type=service" />

</form>

Image upload from frontend in wordpress

function insert_attachment() {
$uploaddir = wp_upload_dir();
$file = $_FILES['poster'];
$uploadfile = $uploaddir['path'] . '/' . basename( $file['name'] );

move_uploaded_file( $file['tmp_name'] , $uploadfile );
$filename = basename( $uploadfile );

$wp_filetype = wp_check_filetype(basename($filename), null );

$attachment = array(
    'post_mime_type' => $wp_filetype['type'],
    'post_title' => preg_replace('/\.[^.]+$/', '', $filename),
    'post_content' => '',
    'post_status' => 'inherit',
    'menu_order' => $_i + 1000
);
$attach_id = wp_insert_attachment( $attachment, $uploadfile );
$fullsizepath = get_attached_file( $attach_id );
$metadata = wp_generate_attachment_metadata( $attach_id, $fullsizepath );
wp_update_attachment_metadata( $attach_id,  $metadata );

if ( is_wp_error( $metadata ) )
echo 'Images not upoaded Correctly Please try Again.';
if ( empty( $metadata ) )
echo 'Unknown failure reason.';

return $attach_id;
}