Skip to main content

Posts

Showing posts with the label php

How to Increase Import Size Limit in phpMyAdmin?

If you are reading this blog then probably you are facing the same issue that I had faced, i.e., how to import the sql-dump-file in the mysql where size of the sql-dump-file exceeds the maximum file size limit of phpMyAdmin. I was having a sql-dump-file (got from client) that I need to import on my local database in mysql. The file size was 186 MB while the maximum size limit of phpMyAdmin was 8 MB. A BiG PrObLeM! Then I searched on Google and found that, there are few tricks available to achieve this. Most of them are related to modifying the php.ini file as given below: Increase the upload_max_filesize limit. Increase the post_max_size limit. Increase the memory_limit limit. Though you can not go beyond 128M. I tried it all. Unfortunately none of them worked for me. But fortunately, I had the full access of my server. So I did it via command-prompt. It is so simple and smooth, if you put all the paths correctly. Let's see the process to solve our problem. Step...

PHP: A webservice to query MySQL database via JSON

Here is a very basic webservice to query mysql database via GET or POST methods. It will return the result in json format. <?php /** * @filename service.php * @author Abhishek Kumar **/ include 'config.php'; function db_query($iQuery, $iReturn) { $output = array(); if($connection = mysql_connect(DB_HOST, DB_USER, DB_PASS)) if($database = mysql_select_db(DB_SCHEMA)) if($result = mysql_query($iQuery)) { if($iReturn) { while ($data[] = mysql_fetch_array($result, MYSQL_ASSOC)); mysql_free_result($result); $output['success'] = $data; } else $output['success'] = $result; mysql_close($connection); } else $output['failure'] = mysql_error(); else $output['failure'] = mysql_error(); else $output['failure'] = mysql_error(); return $output; } $query = (!isset($_REQUEST['query']))? NULL : $_REQUEST['query']; $type = (!isset($_REQUEST['type...

PHP: Session based RAM

Here is a session based RAM. <? /** * @Class: CContainerManager.class.php * @Author: Abhishek Kumar (c) 2008. **/ class ContainerManager { function __construct() { session_start(); Get(); } function Get() { global $Container; $Container = array(); if (isset($_SESSION['RAM'])) { $Container = unserialize($_SESSION['RAM']); } } function Set() { $_SESSION['RAM'] = serialize($GLOBALS['Container']); } function Clean() { if (isset($_SESSION['RAM'])) { unset($_SESSION['RAM']); unset($GLOBALS['Container']); } } function Add($Associate, $Value) { global $Container; if (!isset($Container[$Associate])) { $Container[$Associate] = $Value; return true; } else { return false; } } function Modify($Associate, $Value) { global $Container; if (isset($Container[$Associate])) { $Container[$Associate] = $Value; return true; } els...

PHP: Webpage Publisher

A webpage publishing class. <?php /** * @Class: CPublisher.class.php * @Author: Abhishek Kumar **/ require_once("CTemplate.class.php"); require_once("CFile.class.php"); class CPublisher { private static $oTemplate; public static function initialize() { self::$oTemplate = new CTemplate(); self::$oTemplate->setTemplatePath('asset/template'); } public static function Publish($iContent, $iInclude) { self::initialize(); $Output = self::$oTemplate->ModifyAndDump('Container.dt', array( 'Header'=>self::getHeader($iInclude), 'Content'=>self::$oTemplate->ModifyAndDump('ContainerBody.dt', array( 'Header'=>self::$oTemplate->Dump('Header.st'), 'Content'=>$iContent, 'Footer'=>self::$oTemplate->Dump('Footer.st') ) ), ) ); return $Output; } private static function getHeader($iI...

PHP: Image Uploader

Here is an image uploader with re-sizing methods <?php /** * @file ImageUploader.php * @author Abhishek Kumar **/ $tempFile = $_FILES['Filedata']['tmp_name']; $fileName = $_FILES['Filedata']['name']; $fileSize = $_FILES['Filedata']['size']; $timestamp = date("YmdHis"); $new_fileName = "IMG".$timestamp.strtolower(getFileExtension($fileName)); move_uploaded_file($tempFile, "warehouse/" . $new_fileName); echo $new_fileName; function getFileExtension($iFile) { $iExtension = strrpos($iFile, "."); $oExtension = substr($iFile, $iExtension, strlen($iFile)); $oString = strtolower($oExtension); return $oString; } function imageResizer($image) { //$image = "Database/Foto/IMG_001.jpg"; // Name of the source image list($PictureWidth, $PictureHeight) = getimagesize($image); // Get original size of source image $PictureAspectRatio = $PictureWidth/$PictureHeight; $Width = 160;...

PHP: Directory Handlers

Directory handling methods. <?php /** * @Class: CDirectory.class.php * @Author: Abhishek Kumar **/ require_once("CTemplate.class.php"); require_once("CFile.class.php"); class CDirectory { private $VoTemplate; private $VoCFile; private $Avoid; public function __construct() { $this->VoTemplate = new CTemplate(); $this->VoCFile = new CFile(); $this->Avoid = array(); $this->Avoid['Directory'] = array(); $this->Avoid['File'] = array(".", ".."); $this->Avoid['Extension'] = array(); } public function Directory($iCommand, $iDir) { switch($iCommand) { case 'CREATE': mkdir($iDir, 0700); $oStatus = true; break; case 'REMOVE': rmdir($iDir); $oStatus = true; break; case 'DELETE': $this->deleteDir($iDir); $oStatus = true; break; default: $oStatus = false; } return $oStatus; } private ...

PHP: File Utilities Methods

Utility methods for file handling. <?php /** * @Class: CFile.class.php * @Author: Abhishek Kumar **/ class CFile { public function getFileExtension($iFile) { $iExtension = strrpos($iFile, "."); $oExtension = substr($iFile, $iExtension, strlen($iFile)); $oString = strtolower($oExtension); return $oString; } public function getFileName($iFile) { $iExtension = strrpos($iFile, "."); $oFileName = substr($iFile, 0, $iExtension); return $oFileName; } public function getFileExtensionAlt($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } public function getFileNameAlt($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $filename = substr($str,0,$i); return $filename; } public function CreateFile($iFileName) { if (!$handle = fopen($iFileName, 'w+')) { return "Error: Ca...

PHP: Template Setter

A template setting class for a webpage. <?php /** * @Class: CTemplate.class.php * @Author: Abhishek Kumar **/ require_once("CFile.class.php"); class CTemplate { private $HandleFile; private $Template; private $TemplatePath; public function __construct() { $this->HandleFile = new CFile(); } public function __destruct() { unset($this->HandleFile); } public function FitIn($iTemplate, $iTemplateArgument) { $this->Template = $iTemplate; $this->Template = $this->setTemplate($iTemplateArgument); return $this->Template; } public function ModifyAndDump($iTemplateName, $iTemplateArgument) { $this->Template = $this->getTemplate($iTemplateName); $this->Template = $this->setTemplate($iTemplateArgument); return $this->Template; } public function Dump($iTemplateName) { $this->Template = $this->getTemplate($iTemplateName); return $this->Template; } public function setTemplatePath($iPath...

PHP: Web-service for communicating with MySQL database

Here is a php to mysql communication gateway packaged as a web-service. Gateway.php <?php require_once('Config.php'); require_once('engine/CMySqlManager.class.php'); $VoCMySqlManager = new CMySqlManager(); $VoCMySqlManager->Connect(DB_HOST, DB_USERNAME, DB_PASSWORD, DB_SCHEMA); $_POST['message'] = (!isset($_POST['message']))? null : $_POST['message']; $_GET['message'] = (!isset($_GET['message']))? null : $_GET['message']; $C2S_message = ($_POST['message'] == null)? $_GET['message'] : $_POST['message']; $S2S_information = unserialize(stripslashes(urldecode($C2S_message))); if(isset($S2S_information->COMMAND) && isset($S2S_information->QUERY)) { $S2C_output = array(); $S2C_output = $VoCMySqlManager->Process($S2S_information->QUERY, $S2S_information->COMMAND); if($S2S_information->COMMAND) array_pop($S2C_output); echo urlencode(serialize($S2C_out...

How to Draw & Show Raster-Graphics in Internet Explorer via Pure HTML

Have you ever thought that if it is possible to draw raster-graphics, i.e., pixel based graphics in HTML? Isn’t it interesting if it could be possible? So be ready to be amazed, because with the method that I’m going to describe, it’ll become possible. Let’s start with the number of ways we can show graphics in our web-page. As we know, the standard ways are by using image tag, i.e., <img src="img_name.jpg"> and by using flash file, i.e., *.swf file (advanced way). There is two more ways of doing this; one of them is by using CSS. But it is not supported by most of the web browsers. And I’m not going to describe that, as you could get many articles related to this on internet. Anyways let’s come to the point. The fourth, most interesting way is by using pure html. This is the least known method, in fact nobody else has ever written about it. So technically, the credit of its invention/discovery goes to me. ;) The Technique! We can create an image purely in HTML ...