veedeoo 474 Junior Poster Featured Poster

I really don't see any problem with the database migration to your own cms script, as long as you maintain the same database query used by the tomato..

AND as long as you know the database structure, you should not have any problem in doing any CRUD on it..

veedeoo 474 Junior Poster Featured Poster

try

echo '<link rel="stylesheet" type="text/css" href="style.css" />';
veedeoo 474 Junior Poster Featured Poster

In practice, holes and vulnerabilities of php script becomes probable the moment you type something between the tags below. Before you ventured in writing codes, keep this in mind at all times.. php has a bad twin brother and is equally powerful as php, and this brother's job is to hack anything written in PHP.

<?php   
## All codes below this line, you must protect at all cost. It is your responsibility, and NOT your users..
?>

These vulnerabilities will be escalating in uprecedented rate, when you are not careful. You cannot just let your guards down, whenever you are typing on your code editor. YOu must test everything, before making it available for public access.

PHP is almost synonym to vulnerabilities as windows is almost synonyms to trojans and viruses. However, due to careful programming designs and more attention to detail in security issues, windows users still exist and continue to grow exponentially on a daily basis. The same careful steps and attention to detail in security can be applied, while you write your php program.

Vulnerabilities in php are mostly created by the programmers themselves, but on the other hand we cannot put the blame on them 100%, because it is not easy to protect your codes as you write them. System administrators are also have the sacred responsibilities on updating the server's php version and many other things needed to run a more security friendly servers.

pHP have built-in validate filters and

veedeoo 474 Junior Poster Featured Poster

Hi,

Do all things they suggested above, and then search amazon for books in php if possible look for something that will include introduction to OOP for non-programmers.

!NOTE! do not memorize means to understand the logic behind the subject matter. Learning does NOT always equates to understanding, but understanding is always a proof of learning.

The main key points of learning to program is to be familiar with the syntax, functions, and reserved words and variables.

  1. Read www.w3school.com tutorial on php. DO NOT memorize anything! just read them whenever you feel like reading comfortably.

  2. As you move along the chapters, follow examples by actually writing it on your own and running it own your server. For example, if you are learning how to echo string or variables, you need to do this exeercise on your own.

  3. Read and learn (but do not memorize) all the loops in php, and practice using all of them by actually writing your own script. Write your own example using for, while, foreach loops.. these are commonly use in php and other programming languages.

  4. Read, learn and practice on php conditional statements e.g. if,else, ifelse.. AND the php operators e.g. =,==,<=,>=, +,++... Common usage using the conditional statement if and operator

    if($something == "something"){
    do this;
    }

  5. Read, learn , practice form processing using php by using the following $_GET, $_POST, (not recommended but it is worth experimenting) $_REQUEST. YOU MUST write your own codes for this..

  6. Read, learn, practice …

veedeoo 474 Junior Poster Featured Poster

yes, if you have the video in your server. ffmpeg is needed to create thumbnails.

Based on the resolution of the video itself, we can determine what would be the final dimension of the image. In order to do this, you need the latest ffmpeg distro installed in your server AND the ffmpeg php .

Upon successful installation of the ffmpeg with all of its required packages and plugins, and the ffmpeg php, we can easily determine pretty much all of the information about the video..

For example, we can use simple codes below to extract some important data about the video

  ## we can open the video as an object
  ## we don't want it as boolean persistent

  ## we set dimension as null at first
   $thisVideoDimension = null;

  if($veedeoo = new ffmpeg_movie('uploads/yourVideo.mp4'){
  ## the media is a valid and supported media
$thisMedia = true;
## we get the dimension of the video from the veedeoo object

$thisVideoDimension = array($veedeoo->getFrameWidth(),$veedeoo->getFrameHeight());

}
## we do a simple check if the width is greater than 480
## we can always use the long form of if statement, instead of a short hand as shown below.

$thisWidthForHD = (($thisVideoDimension[0] > 480) && ($thisVideoDimension[1] > 380))? true : false;

## now based on the response from thiswidthforHd, we can construct our encoder.

if($thisWidthForHD){
## hd thumb
$thumb = (PATH_OF_YOUR_FFMPEG." -y -i uploads/yourVideo.mp4 -f mjpeg -s WIDTH_THAT_YOU_WANT x HEIGHT_THAT_U_WANT -vframes 1 -ss TIME_FRAME_TO_CAPTURE -an FILENAME_OF_YOUR_IMAGE.jpg") ;
}
else{
 $thumb = (PATH_OF_YOUR_FFMPEG." …
veedeoo 474 Junior Poster Featured Poster

Hi,

take this for your consideration... on your form method it show post. I am assuming here that the above script is called cart.php as shown in your form codes below.

<form action="cart.php" method="post">

<input type="hidden" name="action" value="update" />

while you are processing it as $_GET as shown on your codes in line 43

elseif(isset($_GET['action']) && ($_GET['action'] =='update')){

If possible, change the above to this

elseif(isset($_POST['action']) && ($_POST['action'] =='update')){

## then do the things they suggested here.

I hope I contributed something here, if not, I wish you good luck .

devianleong commented: Hi veedeoo , I had change to $_post and the error gone. But now the another problem is when I enter 2 in the quantity field and click update, the quantity still remain the same. Any solution ? +0
veedeoo 474 Junior Poster Featured Poster

there is a php function called reflection class as shown here, but never tried it.

veedeoo 474 Junior Poster Featured Poster

@the_prince_Awah,

I will see if I can do a simple str_replace function to get rid of those deviated characters... it should not be that hard.

No! I am not a genius yet.. my professor still labeled me as the mathematical wiz Kid from Fullerton.., but once I am able to solve the famous Riemann hypothesis without inflecting any damage to my brain, then I would probably consider myself as junior genius. But then again that is too much responsibilities I think.. I only dream of setting on a nice beach folding chair while holding a nice cold frappuccino in my right hand that's all :). Programming, I get bored writing them , unless it has a really good purpose out of the ordinary.

veedeoo 474 Junior Poster Featured Poster

Here is a sample decryted part ... just do the rest of them..

function padd_theme_prelude_begin() {
ob_start();
}
add_action('wp_head', 'padd_theme_prelude_begin');
function padd_theme_prelude_end() {
$contents = ob_get_contents();
ob_get_clean();
global $padd_guid;
if (!empty($padd_guid) && (function_exists('padd_theme_credits'))) {
if ($padd_guid === 'c55oe00i-0579-udc9-8oe7-80cfb6io8bce') {
echo $contents;
} 

else {
wp_die('Something wrong.');
}
} 

else {
wp_die('Something wrong.');
}
}
add_action('wp_footer', 'padd_theme_prelude_end');
veedeoo 474 Junior Poster Featured Poster

Hi,

Actually, this is nothing but code base 64 encoding. On your decoded codes, the author replaces the letters with their own calculated equivalent integers .

For example, the encoded messages in the codes above,. uses some form of alpha numeric deviation.. by looking at it or just by glancing at the codes, I can easily assume that the keys are the following.

f3nct42n = function
f = f
u = 3
n = n
c = c
t = t
i = 4
o = 2
n = n

gl2b1l = global

g = g
l = l
o = 2
b = b
a = 1
l = l

e = 5

p1dd_th5m5_cr5d4ts = pbdd_theme_credits

f3nct42n_5x4sts = function_exist

wp_d45('S2m5th4ng wr2ng.'); = wp_die('something wrong');

You can develop your own decrypting mechanism by reading this example here ...

That's pretty much it.... most encryptions especially in organizations they tried to invent some deviation only they know how the keys are deviated..e.g. 12=>a, 13=>b, 4=>y and so forth..

In your code above, I do believe they skept 4 to 5 characters then go backward by 3 then move on by another 4 to 5 and the process goes in cycle.

Again this is just my assumption. The reason I could see it , because I been solving many complex math problems at my school, and this one is the example of assumed assigned values.

veedeoo 474 Junior Poster Featured Poster

here is an image manipulator class I just wrote for this question. Save as image.class.php

<?php

## this image manipulator class was written by veedeoo or poorboy 2012
## feel free to modify, extend this clas as you wish.
## does not have any warranty of any kind

class ReduceImage{
    private $imageLoc = null;
    private $outImageLoc = null;
    private $imageResizePoint = null;


    public function __construct($imageLoc,$outImageLoc,$imageQuality){
        $this->imgLoc = $imageLoc;
        $this->outLoc = $outImageLoc;
        $this->quality = $imageQuality;
    }

    protected function getImageInfo(){
     list($this->x,$this->y) = getimagesize($this->imgLoc);

     return array($this->x, $this->y);

    }
    public function createImage(){
        $this->imageX_Y = self::getImageInfo();
        $this->newImage = imagecreatetruecolor($this->imageX_Y[0],$this->imageX_Y[1]);

        ## in production server use code below
        //$this->newImage = @imagecreatetruecolor($imageX_Y[0],$imageX_Y[1])

      //$this->newX_Y = self::getImageInfo();
      $this->newfile = imagecreatefromjpeg($this->imgLoc);
      imagecopyresampled($this->newImage, $this->newfile, 0, 0, 0, 0, $this->imageX_Y[0], $this->imageX_Y[1], $this->imageX_Y[0], $this->imageX_Y[1]);


     imagejpeg($this->newImage,$this->outLoc,$this->quality);
     ## in production server use code below
     //@imagejpeg($this->newImage,$this->outLoc,$this->quality);

     return $this->outLoc;
     imagedestroy($this->newImage);
     imagedestroy($this->newfile);

    }





}

?>

Sample usage of the class above..You should not have any problem implementing this to your script above.. I don't write full codes for advance users..

<?php

include_once 'image.class.php';

## define quality..quality value range from 10 to 100 10 or worst to highest quality.

$quality = 50;
$inputImage = "someImage.jpg";
$outputImage = "output.jpg";

## instantiate the class
$reducethis = new ReduceImage($inputImage , $outputImage , $quality);

## create the new image with smaller size
$image = $reducethis->createImage();

## display reduced image
echo '<img src="'.$image.'">';


?>

That's it .... good luck.. reference? read more here.

UPDATE! class above has been updated: I removed the possible reduncy of calling another instance of createImage ().

veedeoo 474 Junior Poster Featured Poster

@rotten69,

I am using many different editors depending on what I have to work on. For instance, the above scripts I have provided in this thread was written on browser based editor, using my own php editor class in my portable xampp. I wrote this simple php editor class, so that I can write and test codes right away without the hassle of typing the url just to access the file. What is so cool about this php editor class? I can edit my php codes in browser environment.

For full php developement regardless of framework use e.g. code Igniter, cake php, and doophp , I normally use netbeans IDE php edition. I use it because of the smarty templating plugin for it. NetBeans IDE also have an auto error checking that can make the development process a lot easier. On top of this, I am using my own function and class finder just to make sure I can find the exact page where the functions or classes has been used or instantiated. The Netbean built-in search function is kind of slow, so my solution is to write my own search script that is fast enough to find functions, variables, class in all the files within specified directory.

For android related apps and simple Java, I use eclipse.

For simple and fast coding I use either notepad++ or PHP designer 2007 personal free edition. For the initial writing of the codes, I use the notepad++ first and then to debug …

veedeoo 474 Junior Poster Featured Poster

Hi,

Here is simplest way of doing this (it is too simple that my comments out numbered my actual codes :)). Of course, you must search more on how to improve this. I am in the assumption here that file you are trying to cached is in your server. If it is coming from the external server, then process is slightly different than processes my sample codes will do.

Step One: in your server, create a directory called cache, and give this directory a permission CHMOD of 777 or 755 depending on your host's recommendation.

Step Two: copy codes below and name it anyNameYouWant.php.

<?php
    $cachetime = 10080 * 60;
    ## page naming can be anything it is all up to you
    $pageName = "somepage.html"; 
    $cachefile = "cache/".$pageName;

if(file_exists($cachefile) && (time() - $cachetime < filemtime($cachefile)))  {


    ## the page has been cached from an earlier request

    ## output the contents of the cache file

    include($cachefile); 

    }
else{

    ## we need to include a fresh file or the actual file where we can generate the cache file
    ob_start(); 
    ## include the page to be cached

    include 'pageToBeCached.php';

    ## prepare for writing the cache file
    $filePointer = fopen($cachefile, 'w');
    ## grab the output buffer and write it in cachefile
    fwrite($filePointer, ob_get_contents());
    ## close the file
    fclose($filePointer);
    ## Send the output to the browser
ob_end_flush();
echo "cache file created";

}
?>

Instruction for modification.

1.$cachetime = seconds * 60 ... gives you the time expiration before a new cache file is generated …

SummerNight commented: great answer! +0
veedeoo 474 Junior Poster Featured Poster

Hello Everyone,

Please accept my simple and humble contribution. This script will validate if the user or visitor is a suspected spammer, by utilizing the stopforumspam API.

Example implementation

## example usage. These items can be from database or from form input. The choice of implementation is all up to you.

## the sample info. is an actual spammer based on the API response from stopforumspam. Notice the username did not return to be positive, but ip and email are both positive.

$ip = '23.19.152.194';
$email = 'Kesten@gmail.com';
$userName = 'Tina Lupi';

$check = new SpamCheck($ip, $email, $userName);
$checkIp = ($check->validate_ip()? "This is spammer's IP" : "Not Spammer's IP");

## alternative validation 
// $checkIp = ($check->validate_ip($ip)? true : false);

echo $checkIp."<br/>";


$checkEmail = ($check->validate_email() ? "This is an spammer's email" : "Not Spammer's Email");

echo $checkEmail."<br/>";

$checkUserName = ($check->validate_user()? "This username appeared to be spammer's username" : "Not Spammer's username");

echo $checkUserName."<br/>";

The variables here are the ip, email, and username. Normally, spammers will use the same IP, email or username in any combinations like ip/email, email/username, ip/username.

To get the IP address of any visitor, we can use code below

 $ip = $_SERVER['REMOTE_ADDR'];
 ## alternatively, we can also use getenv
 $ip = getenv('REMOTE_ADDR');

Email and username can be from your form processor. like...

 $email = $_POST['email'];
 $username = $_POST['username'];

The alternative validation can also be set like this

   $checkIp = ($check->validate_ip($ip)? true : false);
   if($checkIp){
   ## redirect code here..

   }

NOTE! There …

veedeoo 474 Junior Poster Featured Poster

Hi,

One of many ways of doing this is to write script following the simple guidelines.

  1. First check if the user is logged in. YES? NO?. If NO?, this is not allowed..
  2. Yes?-> provide a link or form to change the password.
  3. Let the user type in the old password, and the new password. Make it twice for the new password for comparison

    ## e.g.
    <label>Type Old Password</label>
    <input type="password" name="oldpass">
    <label>Type New Password</label>
    <input type="password" name="newFirst"/>
    <label>Re-Type New Passwrod</label>
    <input type="passwrod" name="newSecond"/>

  4. Using $_POST, process the inputted password ( clean it up a little). Compare new passwords .

  5. Connect to your database, validate to make sure that the old password matches the one that is on the database table and the member changing it matches in the username column.

  6. If the validation is a success, update the password column with the new password.

  7. Redirect the user to logout.php and then give the link to login using the new password credentials.
baig772 commented: descriptive +2
veedeoo 474 Junior Poster Featured Poster

you can also give this a try. Just use your command prompt type in the options, the location of the php files or project, type the output file e.g. file.exe , and you are good to go.

You can also add an icon for your converted executable php..

Downside?
The downside is that you will have to distribute some dll files needed by your application e.g. curl dll.
It does not support php 5 and above.

Security?
Watch out for the php function RecursiveIteratorIterator.. I strongly advice you to stay away from using this, unless you have a really good intention behind your application.. would not elaborate on this, but I could already see where the endusers can be exploited by this type of application..

here is a good one... just a tiny snippet of this vulnerability

  <?php
    $dir = new RecursiveIteratorIterator(
     new RecursiveDirectoryIterator('/',true)
    );

    foreach($dir as $file){
        echo $file->getPathname(),"\n";
    }
?>

You run the script above, and you will see what are the things exposed from the enduser's files. Enduser files are exposed including the sitemanager.xml file for filezilla...

Watch out for what you wish for.....

veedeoo 474 Junior Poster Featured Poster

@lastMitch,

I did not know, that it was almost midnight when I responded on this thread. Anyways, I managed to write some simple script to make you edit php, html, css, js files right in your admin area..

I wrote a single class for this, but it needs an upgrade at the moment, so before heading out for school today, I managed to write a simple script that will do as what you need.

Please Protect this script from public access at all cost. I strongly suggest using .htaccess protection on top of the login credentials as admin. NEVER and DO NOT allow any members of your site (if any) to access this script.

I did a test run twice.. and I can confirmed that it is working on my side. The only thing that this file don't have is the fancy highlight capabilities, and systax validation.

Here we go...

sTep ONe.. save this file as stepone.php.. or any name you want will do just as fine..

<?php
####  WARNING! THIS SCRIPT MUST BE PROTECTED FROM PUBLIC ACCESS ###########
## written by veedeoo or PoorBoy 2012
## feel free to use at your application.
## filename : stepone.php


## first we define our file extension allowed. 
$ext = array('.php','.html','.js','.css','.tpl');
## we define our current working directory where the dumper should be looking for files.
$work_directory = getcwd();

## we create a file dumper function
function dump($dir,$ext) {

$d = dir($dir);
while (false!== ($file = $d->read()))
{
$extension = substr($file, strrpos($file, …
LastMitch commented: Thanks for hard work! You made my day! =) +0
veedeoo 474 Junior Poster Featured Poster

Disclaimer! I really don't know how to code in cold fusion. I was never and will probably not learn it. However, besides PHP, I know how to code in C++, C#, C, python, ruby, a little of PERL, and some robotics programming in ROM. I spent most of my time writing and experimenting with OOP PHP for calculator applications ( I have this vision that PHP can be use as Accounting program , and probably will be able to do a better job in a more complex mathematical applications. The reason I have this pretty ambitious vision is that PHP is FREE and can be extend for whatever module we want to add into it.). The language is just too easy for anyone to replicate any applications.

So pretty much, what I am going to tell you here is a one sided point of views, which is not fair for the cold fusion community. I have no intensions of pursuading anyone, NOR claiming that PHP is an ultimate holy grail in web programming.

Learn PHP, because it is the commonly use language in developement. Web developers has been pretty sucessful using php in cms, forum, shopping cart system, video sharing websites, blog e.g. wordpress. There are many stable frameworks developed for PHP e.g. cake, zend, codeIgniter, and many others. There are many extensible templating systems solely intended for the use of PHP developer.

PHP can also carry out an exec, or shell exec right from the script itself. PHP has …

veedeoo 474 Junior Poster Featured Poster

The benefits is that you can build a core where all of the classes needed by your applications are included. In this core, you would have : database CRUD class, content management class, javascript class, templating class, form generator class, and many other classes that are known to be reusable by targeted applications big and small e.g. blog, cms, forum, and many others.

Having those classes in the core, we can easily build an application based on what those classes does.

Fore example, if we have a class to make all kinds of fruit juices, and we want to make an orange juices from a fresh orange, then our controller file can be something like this

 class MakeOrangeJuice extends juices_controller{
   ## since we want fresh orange and not the type of juices in our fruit juices class, we can add it here.
   private $freshOrangeOnly;

      public function __construct(){

      ## since making fruit juices are all alike.. there are always similarities on how to squeeze them, putting them in a glass, and chilling them.
      ## parent construct will be the basic methods on how to create fruit juices as defined in the juices_controller
      parent::__construct();
      $this->freshOrangeOnly = "valencia orange";
      ## we send this thing to our model page
      $this->load->model('orangejuice_model');

      }

Our model page will be the processes or procedures of making the actual orange juice

   ## this is the model

   class OrangeJuice_model extends juices_Model {
    private $quantity;
    private $quality;
    public function __construct()
    {
        $this->load->squeezer();
        $this->quantity = $quantity;
        $this->quality = null; …
veedeoo 474 Junior Poster Featured Poster

Hi,

for the accents, we need to make a separate validation function for it.. e.g.

function isItLatin($username) {
$itIs = false;

if (preg_match("/^[\w\d\s.,-]*$/", $username)) {
    $itIs = true;
}

return $itIs;
}

Based on the accented character validation result, we can use different filters e.g. English, or Latin filters. So for instance, we have an accented input in the form, if the function above recognizes it as part of the acceptable characters within bound, then this

$username = preg_replace('/[^a-zA-Z0-9 ]/s', ' ', $_POST['username']);

Will no longer apply or used, but instead we make the script by using the simple validation as included in the class itself

 ## this will allow usage of the accented characters
 $username = trim($_POST['username']);

For the javascript validation for accented characters, you can read more Here, it is pretty much self-explanatory..

rogerg commented: thx +0
veedeoo 474 Junior Poster Featured Poster

@hwoarang69;

Here is a sample just to help you out..

## first you need to take the form out of the echo zone..
else
    {
    ## it is ok to close PHP below 
    ?>
    <!-- codes below can be pure html.. Don't let your php parser to parse something that can be directly given to the browser -->

   <!-- not loged in(not member) -->

    <h2> YOU ARE NOT LOG IN!</h2>
    <form method="post" action="login.php">
    <strong>Member Login </strong><br/>
    <p id = "login_error"> </p>
    <label>Username:</label>
    <input name="username" type="text" id="username"><br/>
    <label>Password: <label>
    <input name="password" type="password" id="password"><br/>
    <input type="submit" value="Login" name="submit">
    <a href="register.php"> Register! </a>
    </form>
   <! -- we can open or define php document tags again below to close the else curly bracket -->
   <?php
   ## this is what I am talking about.
    }
    ?>

If you take a closer look on your form codes, you will probably notice that I took it our of the echo function. Can't talk much about why?, but the idea is to not deal with too many html embedded inside the php. With this method, you can remove the entire form out of this page, and then put it in different page, save it as from.php and then just include it here, but that is out of the scope of this question.

Now, we move on to your simple form validation codes... I hope you will be working on this a little later. Otherwise this type of validation will not thrive in production server. Below is your …

veedeoo 474 Junior Poster Featured Poster

Hi,

You should go by Ardav's suggestion.. (I mean diafol :) ). That should get the job done, but if want to do some simple xml parsing, then you can try codes below. Not the best one, but can also get the job done ( I hope :))..

Here we go... simple DOM object..

## don't forget to provide the location of the actual xml file.
$xml = "someXml.xml";
$doc = new DOMDocument();
  $doc->load( $xml);
  ## lets read the code block
  $records = $doc->getElementsByTagName( "code" );
  foreach( $records as $record )
  {
  ## parse the zip code
  $zip = $record->getElementsByTagName( "postalcode" );
  $zip = $zip->item(0)->nodeValue;

  ## parse the city
  $city = $record->getElementsByTagName( "name" );
  $city = $city->item(0)->nodeValue;

  ## parse the latitude
  $lat = $record->getElementsByTagName( "lat" );
  $lat = $lat->item(0)->nodeValue;

  ## parse longtitude.
  $longtitude = $record->getElementsByTagname( "lng" );
  $longtitude = $longtitude->item(0)->nodeValue;

  echo "<p>Zip Code: ".$zip."<br/>City: ".$city."<br/>Latitude: ".$lat."<br/>Lontitude:".$longtitude."</p>";
  }

that's pretty much about it...

diafol commented: good example +14
veedeoo 474 Junior Poster Featured Poster

I am currently using Cleditor. It's pretty light 1 js file, one css file, and two images, a total bandwidth consumption of less than 10k.

diafol commented: Nice +14
veedeoo 474 Junior Poster Featured Poster

Hi,
You can try logging in the admin first, and then generate a random security salt, assign this salt to session e.g. $SESSION['security'] = 1653e9gg4r99s@$7700)llls434rf853~, and then on your member's database table, you must insert this in session column. While the admin hops over pages, you can double check if the session salt still matches with the one recorded on the database. Session expiration will help also e.g. 45 minutes to generate a new salt, update database session column. Upon logout of the admin database session entries should also be unset. In my logged in sytem, I post salt as session, and then the IP address of logged in members.

veedeoo 474 Junior Poster Featured Poster

Ok guy,

Here we go.. obviously I over slept up to the point where my professor sent someone in my dorm to wake me up.

I will just paste it here so that if other people may find this post useful, for whatever it's worth.....Ready?

Step One: In your htdocs directory, create a new directory called blob, inside the blob directory create another and name it uploads, and the rest are simple as copy and pasting. Copy sql below to create a new database table and name it "test". You are welcome to add more columns to your need.

 CREATE TABLE IF NOT EXISTS `images` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `image` longblob NOT NULL,
 `thumb` varchar(100) COLLATE latin1_general_ci NOT NULL,
 `title` varchar(255) COLLATE latin1_general_ci DEFAULT NULL,
 PRIMARY KEY (`id`)
 ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci ;

The above sql is pretty common, with one EXEMPTION.. I used longblob. This will allow you to upload or store bigger files at least 3-5mb.

Step Two: Create a file named settings.php..actually this is just the database credentials file. pretty basic

 <?php
 ## filename settings.php
 $user = "root";
 $pass = "";
 $host = "localhost";
 $db_name = "test";
 ?>

Step Three: Create a new file called function.php

 <?php
 ## filename: function.php
 ## simple class
 function simple_func($sql){
 ## define your database connection credentials
 include 'settings.php';

$conn = mysql_connect($host,$user,$pass) or die(mysql_error());
$db = mysql_select_db($db_name,$conn)  or die(mysql_error()); 

$result = mysql_query($sql, $conn) or die(mysql_error()); 
## we check and make sure we are getting a …
phorce commented: You are amazing lol. +4
veedeoo 474 Junior Poster Featured Poster

Hi,

Ans 1. FTP is a lot faster than your conventional file management in cpanel. It will be a lot easier to change file and directory permission using FTP program e.g. filezilla.

Ans 2. Yes, anything that refers to instruction such as create a new directory in your root directory.. will be beneath the public_html directory (please read extra info. below). The reason is that above public_html are not viewable to the browser. However, there are cases where some scripts e.g. php, perl can be placed above the public_html, but that out of the scope of your question.

Ans3. The image directory should be created inside the public_html directory.. Normally, your hosting provider will tell you where to put all of your files, but by default it is the public_html.

Extra info.

file permission. sometimes, books will instruct you to give permission to files or directory. To change or set permission to specific directory or files using FTP, just right click on the directory or file, and then select file permission.. type in the number suggested by the author.. e.g. 0777, 777, 0755, 755. again it all depends on server settings e.g apache module, cgi or fast cgi. Most servers, will assign persmission to a newly created directory with 755.. again it all depends in the server configuration.. e.g apache module or fast cgi?

In environment like shared hosting account, you would notice that you can easily add new domains under one account. So, the files inside the public_html belongs …

JorgeM commented: well done! +4
veedeoo 474 Junior Poster Featured Poster

Hi,

let me test it on my joomla, but try dschuett's suggestion first. It should work...

UPDATE: Sorry, when I editied my response the array sample got deleted. Here it is again.

$thisArray = array('item1','item2','item3','item4')

$_SESSION['items'] = $thisArray;

## to access the array, you just have to start session
## for example,
session_start();

## item1 to 4 
$_SESSION['items'][0];
$_SESSION['items'][1];
$_SESSION['items'][2];
$_SESSION['items'][3];
dgibbons82 commented: Thanks for the help! My apologies for taking so long to respond. +0
veedeoo 474 Junior Poster Featured Poster

Hi,

Yes you can do it.. here is sample. This example demonstrate how to assign array in session.

1.php

<?php
session_start();
   ## page one
   $sku = "12345678_SKU";
   $itemID = "580007";
   ## make sure the above are not empty
   if((!empty($sku))&&(!empty($itemID))){

   $itemAr = array( $sku, $itemID );
   $_SESSION['items'] = $itemAr;

   }

   echo '<a href="2.php">Go to page 2</a>';
?>

2.php . I am not a big fan of php shorthand tags, but I will use it here..

 <?php
   ## filename 2.php
   session_start();
   ## let's access items in the session and move them to form input
?>
   <form method="post" action="3.php">
    <p>
   <label>SKU</label>
   <input type="text" name="sku" value="<?=$_SESSION['items'][0]?>"/><br/>
   </p>
   <p>
   <label>Item ID</label>
   <input type="text" name="itid" value="<?=$_SESSION['items'][1]?>"/><br/>
   </p>
   <p>
   <input type="submit" name="submit" value="Next"/><br/>
   </p>
   </form>
   <!-- end of form -->

3.php This file demonstrate how we can unset session for specific array assign to it, and then assign a new set of array.

 <?php
   ## filename 3.php
   session_start();

   ## since that this page is now relying on the items submitted in the form, we can unset our session['items']


   if((isset($_POST['submit']))&& (!empty($_POST['sku']))&& (!empty($_POST['itid']))){
   ## unset session from two previous page to set these form items
   ## if browser is going to go back and forth between pages, do not unset the first session, instead create a new one.
   unset($_SESSION['items']);

   ## I added a suffic -> _two on the posted items, for 4.php checkpoint. We want to make sure the session has been unset if wa
   ## we want it unset.
   $sku1 = $_POST['sku']."_two";
   $itid = …
LastMitch commented: Thanks for the example! +2
veedeoo 474 Junior Poster Featured Poster

did you try?

 while($row = mysql_fetch_array($result)) {
 $thisArray[] = $row;

 }
veedeoo 474 Junior Poster Featured Poster

Please double check on my added Later info. above. I normally type in the codes raw in this text area, so changes on my posted codes can occur between the time I posted it upto the set time, I can no longer edit.. it should work. Your corrected code should be like this...

$result = mysql_query("SELECT * FROM track ORDER BY rand()");
    while($row = mysql_fetch_array($result)) {
     $url = preg_replace("/^http?\/\/(.+)$/i","\\1", $row['car']);

    ?>
    <td> <a href="http://<?php echo $url; ?>" class="mylink" target="_parent"><?php echo $row['tag'];?></td>
    <?php
    }

I remove the short tags, because I don't know your server settings. It is a lot safer this way..

Yes, it will strip http// ONLY, and not www.someurl from your database as row['car'] value. the link of the corrected codes above should be like this http://www.whateverDotCom.

Kniggles commented: missed a : however very helpful and very quick and thank you,jerrijeff. +2
veedeoo 474 Junior Poster Featured Poster

I just wan't to make sure that we can duplicate the same error on a regular link..Can you please create a new file , paste the code below and save the file as anyname.php , load this file to your server..

  <?php
 $url= "daniweb.com/web-development/php/threads/422216/url-not-working-right";
 $link = "daniweb";
   echo '<td> <a class="mylink" target="_parent" href="http://'.$url.'">'.$link.'<br>';
?>

if you click the link on it, it should take you back on this thread. Please double check that : is not missing on the link.

To make sure that it is not a parsing problem, the code can also be use.. Assuming that php shorthand is enabled on your server.

 $result = mysql_query("SELECT * FROM track ORDER BY rand()");
   while($row = mysql_fetch_array($result)) {

 ?>
    <td> <a  href="http://<?=$row['car']?>" class="mylink" target="_parent"><?=$row['tag']?></td>
<?php
 }

If the link still don't connect to the tartget url when http:// is used, it is the target site that has a DNS problem.

One last note for you to consider, if the row['car'] is printing http:/someDomainDotCom, then the href above should only be like this

   href="'.$row['car'].'"
veedeoo 474 Junior Poster Featured Poster

The reason I made you echo the items coming form your database is to make sure that we are getting something. Now, that we are sure of that. Let's put back the code only with the following correction.

echo '<td> <a href="http://'.$row['car'].'" class="mylink" target="_parent">'.$row['tag'].'</td>';

At first, I did not notice that your href is way outward .. I am not sure if this is what is causing the : to disappear, but I think it is worth trying. On the other hand, I don't think it would be the case though..

veedeoo 474 Junior Poster Featured Poster

hi,

can you change your code above to this..

//echo '<td> <a class="mylink" target="_parent" href="http://'.$row['car'].'">'.$row['tag'].'<br>';

echo $row['car']."<br/>";
echo $row['tag']."<br/>";

Tell us what do see on the screen..

veedeoo 474 Junior Poster Featured Poster

try,

   echo '<td> <a class="mylink" target="_parent" href="http://'.$row['car'].'">'.$row['tag'].'<br>';
veedeoo 474 Junior Poster Featured Poster

try,

$user2 = " this / ?  is ~~ + | $ ##  * 7 ) user  name  <br/>";

    $user2 = preg_replace('/[^a-zA-Z0-9 ]/s', '', $user2);
    $user2 = trim(str_replace(' ','',$user2));

    echo "<br/>".$user2."<br/>";

Let the preg_replace to get process first, and then the trim string replace. They cannot be condensed I think.. I don't have the chance to test it.. Please let me know if the codes above worked..

veedeoo 474 Junior Poster Featured Poster

try..

 $username = " this  is  user  name  ";
   $username = trim(str_replace(' ','',$username));
   echo $username;

for registration, try

  $username = preg_replace('/\s\s+/', '', $username);
veedeoo 474 Junior Poster Featured Poster

Hi,

Move all these before the while loop..

 <div class="body2">
  <div class="main">
  <section id="content">
  <div class="wrapper">
  <article class="col1">
  <div id="slider">

and then after the closing curly bracket of your while loop, move these.

    </div>
    </article>

By the way, where is the opening tag of article?

veedeoo 474 Junior Poster Featured Poster

Hi,

Session will work on this type, I mean even in a much more complicated applications. Session can even handle an array, and it will save the data in it , until it is unset -> removes the item in the session but not the session itself, OR session destroy-> which eventually destroy everything including the session.

Script below is something I wrote for testing. I used this for capturing a dynamic playlist and viewed videos history.. pretty much similar to what you see on youtube. I wrote this script to allow users to go back to items they already watched.

I tweaked it a little bit. I removed some of the items that will not make sense if included in this discussion. I also rewrite it for your needs. The only thing I did not do is to create two pages, and I used POST instead of GET.

This script is easy to modify. Again, data submitted through this form are not sanitized. It will be your responsibility to test it and mocked this script to your application.

The script is pretty much commented already, up to the point that I felt myself as being extremely becoming redundant.

Here is the code.. this will be the final codes I'll be writing for today. My wrists are feeling pretty bad now.

Save this as test.php, load the file on your server, and direct your favorite browser to it.

<?php
## first we create a session
session_start();

## second we create …
veedeoo 474 Junior Poster Featured Poster

Just in case people want to do the same, which I don't really recommend. However, there are some cases where the content of the site requires mobile users to be redirected to the mobile version of the mainsite. Here is the code for it.

<?php

## borrowed these codes from someone, but forgot his site url

$useragent=$_SERVER['HTTP_USER_AGENT'];
if(preg_match('/android|avantgo|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i',$useragent)||preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|e\-|e\/|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(di|rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|xda(\-|2|g)|yas\-|your|zeto|zte\-/i',substr($useragent,0,4)))

## Redirect URL
header('Location: mobileVersion.xml');

?>

If you don't want an auto redirection, then just modify this part of the code

  ## mobile content redirect url
header('Location: mobileVersion.xml');

To something else like link to the mobile version of the site. Something like this

 $showMobileLink = true;

Then somewhere in the header section of the stie if so equiped, I would do like this.

 if($showMobileLink){
  $mobilelink = '<a href="mobileVersion.xml")>Mobile Version</a>';

 }
 else{
 ## you can remove this or just keep it this way
  $mobilelink = '';
 }

Just call it anywhere you want the link to show up.

  echo $mobilelink;

That's it.. the good thing about my recommendation is you don't have to spend a single penny. You can always use .html for the file. I use xml, because that was the one I used on my previous project, but apple turn it down, because my plugin was not sutiable for general audience.. I wrote an iphone apps to spice up the mobile surfers, but …

HayLift commented: Thank you. +0
veedeoo 474 Junior Poster Featured Poster

Hi Pritaes,

I think that would require a little bit of work... people were talking about it, why it has to be cache key instead of a name? This person got some tweaks, but encounter some minor problems.

Twig should work on this limitation. I hope it will be pretty soon.

Meanwhile, the file responsible for writing and loading the cache/template file is the Twig/environment.php. They have an updated and modified version of this file at gitHub. The most updated distribution with fixes is Here.

Moments ago, I ran a simple script with cache enabled, the cache sub-directories and files were arranged this way.

cache
->templates
--->of->f1->the actual child template cached file.
--->16->5d->the actual master template cached file.

Template nesting and inheritance in twig is exactly the same as in Smarty, with one exemptions on the grandchild's ability to pick up some of the grandparent's (master template) defined block characteristics.. for example, the master template can have the following blocks. The same thing in smarty master template, all css, js and valid html tags must be included here.

For other people who just stumbled upon this discussion, this is the file where all of the styling and beautification must be focused. Designer can have all of freedom to work on this file. There is nothing to break here really. They can delete or missed-up on the curly and percent symbols all day long, our php script will remain safe in the …

pritaeas commented: Much appreciated. +13
veedeoo 474 Junior Poster Featured Poster

Twig's cache is almost the same as smarty..with the only exemptions of twig is doing it much better, because the cache directory is created automatically, and it can detect any changes made on the template files.

Normally, without cache we can initialize twig environment like this

 ## initialize twig environment without cache
 $twig = new Twig_Environment($loader);

To enabled cache, we can just replace the initialization above with

   ## twig environment initialization cache enabled
   $twig = new Twig_Environment($loader, array(
   'cache'       => 'cache/templates',
   'auto_reload' => true
  ));

The cache page of the tpl file will be located the root of the script if cache/templates does not exist.. twig will create them automatically.

Now the beauty of twig is its ability to detect any changes in the template file.. if changes were made after the cache file has been recompiled, the twig will use the auto reload function.

In my example code above, I made auto_reload equal to true. So, pretty much it will be a self serving, whenever it detects changes on template file.

The one I like the most about twig is its ability to do a data dump. In smarty, people normally do this

   while(SomeRowsFromDatabase){
   $value['one'] = $row['one'];
   ## sometime it should have to be like this (string)$row['one'];
   $value['endOfItems'] = $row['lastRow'];

   $valueOut[] = $value;

   }
   $smarty->assign('valueOut', $valueOut);

While in twig it is a lot shorter and faster I think...

 ## twig approach
 while(SomeRowsFromDatabase){
   $valueOut[] = $row; 

   }

   ## send the above data to …
veedeoo 474 Junior Poster Featured Poster

The problem in the mysql_fetch_array(), I just realize that when you insert something from another table to a new one, once the query is execueted.. it is done.., and we won't be able to pick up the result..

Before goin on further, on your achive table, is the id set as auto increment??? Make sure that it is set to autoincrement otherwise, the archive table will not have an id value.

To check if the insert to the archive table has been executed. Using the php admin take a look at the archive table.. I am pretty sure , even with the error above.. the script managed to insert..

to fix the error above, we need to create a query specific only to the inserted values on the archive table.. However, if the ID on the archive is not set to auto increment the query below will bring another error. So, please double check..

Here is the new query for the newly posted data on the archive. This will serve as a confirmation on what was posted by the first query.

     $result2 = mysql_query("SELECT * FROM archieve WHERE id='".$id."'")
      or die (mysql_error());          
      while ($row = mysql_fetch_array($result2))

     {
     echo '<td><center><a href="write_message.php?id=1">' . $row['fullname'] . '</a></center></td>';
     echo '<td><center>' . $row['username'] . '</center></td>';
     echo '<td><center>' . $row['password'] . '</center></td>';
     echo '<td><center>' . $row['fullname'] . '</center></td>';
     echo '<td><center>' . $row['course'] . '</center></td>';
     echo '<td><center>' . $row['year'] . '</center></td>';
     }

Before running the updated script above make sure to delete the entry on …

veedeoo 474 Junior Poster Featured Poster

HI,

You need to remove the * from your select. Try using this

   $result=mysql_query("INSERT INTO archieve (username, password, fullname, course, year) SELECT  username, password, fullname, course, year FROM original_table WHERE id='$id'")

Don't get too agressive on your DELETE query.. YOu need to make sure that data has already been posted on your achive table.

Put the delete query somewhere else, not on the very top..

veedeoo 474 Junior Poster Featured Poster

hi, take a look at this.

veedeoo 474 Junior Poster Featured Poster

Hi,

change this

 $html= str_get_html($outhtml); 

With this...

 $html = file_get_html($url);

The output should give you something.. YOu just need to use the regex that Pritaes have given you to sort out the jpg from gif, to eliminate the shopping cart images and the search..

Let me know... what is the outcome though...

veedeoo 474 Junior Poster Featured Poster

These are the reasons why I LOVE PHP over anything else.. I mean I also like active server language, but I think PHP is more extendsible. PHP can also be a very powerful coding language , if either one or all are used.. framework, templating system, OOP..

The same thing with ASP, php just need a descent templating system.. like what Pritaeas have recommended. I prefer smarty or twig, but dwoo is something I can fall back into.

In smarty you can make one master template, and then just extends it for every pages you want to create.. Besides, it will never complicates with the script updates, because each page has its own php file, you are just assigning them to your template file..

Please allow me write an example. Just because I am getting bored on my current google/youtube API work they want me to overhaul.

I prefer using some of my precious time in promoting and convincing other people why PHP is a good programming language if not excellent? In PHP you can also have a master template .

In my example let us call this main.tpl all of the major css and design aspects of your site must be included here...

          <!-- filename main.tpl -->
          <html>
          <head>
          <title>[block name=title][/block]</title>
          <meta name="keywords" content="[block name=meta][/block]"/>
          </head>
          <body>
          <div id="mainwrap">
          <div id="leftcol">
          <!-- you can assign your left column content here, by creating a left column block -->
          [block name=leftcontent][/block]
          </div>
          <div id="maincontent">
          <!-- you can assign your maincontent …
pritaeas commented: Nice. +13
veedeoo 474 Junior Poster Featured Poster

Hi,

did you try adding ???

  parent::executeIndex($request);

just below

 public function executeIndex(sfWebRequest $request)
 {

Not sure though, I only used this framework for less a month... So, my memory was not able serialized whatever I did on my practice applications.

veedeoo 474 Junior Poster Featured Poster

Hi,

add this just above $result

 $band = $_POST['band'];
veedeoo 474 Junior Poster Featured Poster

Hi,

Try changing this

 $query = "SELECT * FROM interviews WHERE vacancyid = $applyid'";

To

 $query = "SELECT * FROM interviews WHERE vacancyid = '$applyid'";

Double check your queries above and do the same..

You can also change your code to this...

 if($row["vacancyid"] == $applyid)
 {
  ## show your form here
  }
  else{
  echo "no interviews are be held";

  }

It is a lot easier for your script to evaluate the $applyid equal to vacancyid, because applyid is your parameter in your query. It could have been an easy query, but since you need to echo the form with values from the same query, we don't have a choice but loop over.

veedeoo 474 Junior Poster Featured Poster

@Muralikalpana,

Just to clear some of my doubts, can you run this script on your wamp server

 <?php
 var_dump(curl_version());
 ?>

Did you see anything on the screen?

NO? Run

 <? phpinfo(); ?>

Look for your server loaded configuration file .. e.g. apache/bin/php.ini OR php/php.ini.. based on the loaded configuration file, find the php.ini file, load the php.ini file on your editor and then find

   ;extension=php_curl.dll

Change it to

   extension=php_curl.dll

Go to your wampp/php/ extension directory and double check if the php_curl.dll is present... if not, go and check the wampp website on how to enabled and add extension on their distros..

I am not sure if you can trim cURL output.. coming from the exec handler... I need to read about that..The output is already known by your server to be an array. So adding (array) might be an overkill..