veedeoo 474 Junior Poster Featured Poster

Don't forget the portables, just in case you need to write codes while in-flight.. I use either nginx or xampp portable for the server. Eclipse and notepad++ as editor. All of them fit in one little flash drive. On a desktop environment, I practically tried all of the things mentioned above.

I always use notepad++ whenever I get annoyed by auto-completion. Notepad++ is pretty cool I think. I am not a very big fan of DW kind of editor. I believe simple and nice highlight is all I need for PHP and something that is not trying to auto-complete my codes. But for writing applications in various languages, eclipse and NetBeans are my choices ( at least for me).

veedeoo 474 Junior Poster Featured Poster

Hi,

Yes, that would be a good choice. The latest Symfony and Zend frameworks put everything into an array.. I don't have any symfony or Zend in front of me at the moment, but as far as I can remember while working with these two frameworks, both have sessions and cookies as an array.. it was something like this

## in symfony they have something like this

    public static function getSession($session_x = array(), $cookie_x = array(), $user_credentials=array()){

    ## something here

    }
veedeoo 474 Junior Poster Featured Poster

here is a nice example of doing date validation. If you need a more complex example than the ones found on php.net, please let me know....

veedeoo 474 Junior Poster Featured Poster

try using an iframe,.. not ideal, but that is all I can think of right now..

something like this

echo '<iframe>';
echo html_entity_decode($body);
echo '</iframe>';

seach google for iframe css to style the iframe..

veedeoo 474 Junior Poster Featured Poster

View the source of the page and look for the value of your video url from this

<source src="videos/somefilename" type='video/mp4' />

Browse and locate the somefilename in videos directory. If the video is not there, the upload is not successful, because of either the script timed out or the setting in your php.ini file has been exhausted..

OR, if the video is huge in size, the browser needs to download the entire video place it in the temp directory, before it can start to play. This is one of the disadvantages of using html5 player over the conventional flash player.

ADDITIONAL Info.

Unlike the flowplayer or jwplayer, html5 player do not support pseudo-streaming. Pseudo-streaming is the ability of the player to read the metadata of the video. In flv files, these metadata are injected by an application called flvtool2, while in mp4 videos encoded in h264 codec, metadata are injected by an application called mp4box, and yes it is all run from the php backend.

Both mp4 and flv videos that are not injected with metadata will not pseudo-stream. In the case of MP4 videos, the process is different because the moov atom is located in the back OR at the end of the video file. The MP4Box can move this moov atom in the fron of the file, so that flash players can pseudo-stream it,, meaning the browser or the player does not need to download the full video, before it can start playing.

If you will be …

veedeoo 474 Junior Poster Featured Poster

Hi,

This

<?php echo $video; ?>

Should have a value of file location and extension e.g. video.mp4.

Some Concerns about your codes..
Where is your .ogg video for firefox, opera and chrome browser support?

If you don't have enough space to spare for the remaining video format, I think it is more feasible to use flowplayer or jwplayer to make everyone happy. Otherwise, you can write your codes with fallback function html5 to flash if needed.

veedeoo 474 Junior Poster Featured Poster

Hi,

You need to provide us what date format you want to validate with. There are few of them you must decide..

veedeoo 474 Junior Poster Featured Poster

Hi,

Facebook does it like this.., and here is an example of an open graph if I am going to write it for Daniweb.com . Warning image url is an assumed location.

<meta property="og:title" content="Your Own Open Graph Meta Application"/>

<meta property="og:image" content="http://daniweb.com/images/daniweb_logo.jpg"/>

<meta property="og:site_name" content="Daniweb"/>

<meta property="og:description" content="An online discussion community of IT professionals. Forums to get free computer help and support."/>

To parse it, look for my previous post about 5 days back... I wrote an example on how to handle meta tags parsing..

Here are the codes I used, but you still need to read my instructions from my previous post, and adjust the url to your application... This can also work outbound and inbound through $_GET..

$url = 'http://watch32.com/movies-online/return-to-the-blue-lagoon-2766';
$file = useCurl($url);
$html = str_get_html($file);

foreach($html->find('meta[name=keywords]') as $element){
       echo $element->content.'<br/>';

       }

echo '<br/>';
foreach( $html->find('meta[name=description]') as $desc)
$movie_detail = explode("|", $desc->content);
echo 'Title : '. $movie_detail[2].'<br/>';
echo 'Director :'. $movie_detail[3].'<br/>';

$casts= explode(",", $movie_detail[4]);
echo 'Casts<br/>';
foreach($casts as $actor){
echo $actor.'<br/>';

}

function useCurl($url){
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; MSIE 7.0; Windows NT 6.0; en-US)');
            curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,10);
            curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
            curl_setopt($ch, CURLOPT_AUTOREFERER, true);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            $output = curl_exec($ch);curl_close($ch);
            return $output;
            unset($output);
          }

This little piece of code shown below,

 foreach($html->find('meta[name=keywords]') 

Should be change to

  foreach($html->find('meta[property]')    

Then just iterate the array, and finally grab the result by defining which index you need.. for example

  foreach($html->find('meta[property=title]') 

Should give you **Your Own Open …

veedeoo 474 Junior Poster Featured Poster

It is also working on my computer.

veedeoo 474 Junior Poster Featured Poster

Hi,

You can use xampp, wamp,nginx portable ( this require a lot of work, but lighter). I would recommend for you to use xampp, because just in case you will need more help in setting it up, there are many people that can help you out.

No, you do not need to make any changes when you put it online or the production server. In fact, you can directly import your local mysql database tables to your online database.

The public_html in xampp is called htdocs.

veedeoo 474 Junior Poster Featured Poster

Hi Dani,

Might not be the best answer, but I think among the few PHP functions that does not go really well with the suppressor, unserialize is one of them..

The reason is that, even with the suppressor, unserialized($var) will always gives an error if $var is not serialized.

Warning: unserialize() expects parameter 1 to be string, array given

Besides the much bigger frameworks e.g zend, cake,codeIgniter, I found wordpress to also use this function to store data..

I don't mean any harm to the wordpress people, and I honestly sorry if I have to disassemble this part of the codes for the reason of GOOD cause..

So, my idea is to check if the $data is serialized before returning the method is_serialized..

Here we go !WARNING! Borrowed from Wordpress without authorization.

Let's create a new method to check and confirm that $data is serialized or not..(This returns Boolean)

private function checkIf_serialized( $var ) {

    if ( !is_string( $var ) )
        return false;
    $var = trim( $var );
    if ( 'N;' == $var )
        return true;

    if ( !preg_match( '/^([adObis]):/', $var, $s_chars ) )
        return false;

    switch ( $s_chars[1] ) {
        case 'a' :
        case 'O' :
        case 's' :
            if ( preg_match( "/^{$s_chars[1]}:[0-9]+:.*[;}]\$/s", $var ) )
                return true;
            break;
        case 'b' :
        case 'i' :
        case 'd' :
            if ( preg_match( "/^{$s_chars[1]}:[0-9.E-]+;\$/", $var ) )
                return true;
            break;
    }
    return false;
}

The is_serialized method above can be rewritten as follows

public function is_serialized($data)
    {

    //return (@unserialize($data) …
veedeoo 474 Junior Poster Featured Poster

Dude,

It can't be the same result if you are following my first response, Where it says look for the value of the "Loaded Configuration File"..

The value assigned to the loaded configuration file is the location of the php.ini file currently being loaded by the apache server to initialize the PHP support.. that's simple..

DO NOT EDIT the php.ini file located in the C:\WINDOWSthis is a system php.ini file. Apache needs to at least tell the mother ship what it intends to do..

This-> Loaded Configuration File and NOT this ->** Configuration File (php.ini) Path**

Normally, the loaded configuration file is located in the php directory compiled with the apache2..for example

C:\php\php.ini 

If you are using wamp or xampp, it is more likey located in

C:\xampp\php\php.ini 
veedeoo 474 Junior Poster Featured Poster

Try,,

Programming PHP, 2nd Edition
by
Rasmus Lerdorf,
Kevin Tatroe,
Peter MacIntyre

Just in case you need to know who Rasmus Lerdorf is, please read here. This is the guy who created PHP. Will it make the book Good?

Yes, and NO...

Yes -- because it will teach you the proper construct in PHP.
NO -- because some of the functions introduce in the book were already been or about to be deprecated.

Will I still buy this book? Of course I will, it is on sale at the Barnes and Noble for $1.99 .. you can't go wrong for a buck and 99.

Practice and lots and lots of practice can help a lot in learning PHP

veedeoo 474 Junior Poster Featured Poster

To help you out more, this is how the default setting would look like

;;;;;;;;;;;;;;;;;;;
; Resource Limits ;
;;;;;;;;;;;;;;;;;;;

; Maximum execution time of each script, in seconds
; http://php.net/max-execution-time
; Note: This directive is hardcoded to 0 for the CLI SAPI
max_execution_time = 30

; Maximum amount of time each script may spend parsing request data. It's a good
; idea to limit this time on productions servers in order to eliminate unexpectedly
; long running scripts.
; Note: This directive is hardcoded to -1 for the CLI SAPI
; Default Value: -1 (Unlimited)
; Development Value: 60 (60 seconds)
; Production Value: 60 (60 seconds)
; http://php.net/max-input-time
max_input_time = 60

; Maximum input variable nesting level
; http://php.net/max-input-nesting-level
;max_input_nesting_level = 64

; How many GET/POST/COOKIE input variables may be accepted
; max_input_vars = 1000

; Maximum amount of memory a script may consume (128MB)
; http://php.net/memory-limit
memory_limit = 128M

change this

 ; max_input_vars = 1000

to this

 max_input_vars = 3000

comment line in php.ini file is

;

If you have suhosin installed, consult their docs.

veedeoo 474 Junior Poster Featured Poster

To answer your last question, you can either increase it to or higher. It is your call. Don't forget to restart the apache.

max_input_vars = 3000
veedeoo 474 Junior Poster Featured Poster

I forgot to tell you that you will need to restart the apache server.

veedeoo 474 Junior Poster Featured Poster

Hi,

copy, paste to notepad, save as whateverfile.php, and direct your browser to this file.

<?php 

    phpinfo(); 

    ?>

Look for the value of this

Loaded Configuration File 

Using your windows explorer and locate the php.ini file as shown on your Loaded Configuration File .

Change the values of the following

post_max_size
upload_max_filesize

it is ok to give it a higher value like 200M.

last thing, change this value to a higher value as needed by your php applications..

max_execution_time
veedeoo 474 Junior Poster Featured Poster

Hi,

Please forgive me if I having doubts about these codes (shown below)... maybe this is right and I am definitely wrong. I am not sure though, maybe I was asleep at school when they cover this type of indexer...honestly,

while($row = mysql_fetch_array($result))
    {
    $partners_id[]= $row['web_customised_partners_id'];
    $image_value[] = $row['image_id'];
    $image_filename_value[] = $row['image_filename'];
    $description_value[] = $row['description'];
    $url_value[] = $row['url'];
    $case_study_id[] = $row['web_customised_partners_case_study_id'];
    $CaseStudyTitle[] = $row['CaseStudyTitle'];
    $active[] = $row['active'];
    $show_in_banner[]=$row['show_in_banner'];
    }

Can you test it just this part, and try echoing items in the array?.. For instance, we can test it like

echo  $partners_id;

which is according to your codes it is equivalent to $row['web_customised_partners_id'];

The reason I am asking you test it this way because, I have the assumption (again might be wrong again), it should bring me an **Array to string conversion ** error, unless the error reporting is totally suppressed.

veedeoo 474 Junior Poster Featured Poster

hi,

try
1. Open xampp directory
2. Locate crash.txt sometimes you will have a lot of these files.
3. Read the latest

force stop and restart

force stop: in the xampp directory find the xampp_stop.exe this is the one with the icon. Click on the icon...wait for the command prompt to disappear.

force start: If the above procedure has been sucessful, click on the xampp_start.exe. Again this is the one with the icon. Wait for the command prompt to appear. Minimize the command prompt and do not close.

If using the force start, you are bypassing the xampp control panel. Some versions of xampp are known to have bugs in it, but not 100% can be blame to xampp.

In newer versions of windows, you may want to run the xampp as administrator or whatever is equivalent to root in windows..

Sometimes, when windows security prompt appeared asking you for the permission if apache2 and mysql are allowed to run, you probably missed it.

veedeoo 474 Junior Poster Featured Poster

cool, can you post your database structure, so that I can test it on my side. DO NOT include any personal information of the members, just the bare database.. My Father is part Irish/Italian/Filipino (The best combination for temper and Alcohol just kidding :), but the most handsome and nicest Dad I could ever wish for).

veedeoo 474 Junior Poster Featured Poster

I hope you don't mind me asking. What does this comment mean?

//KONTI PA!

I don't mean it in a bad way, I normally write my comments on the top. It just caught my attention.

veedeoo 474 Junior Poster Featured Poster

Hi,

You can create two simple functions to catch all the form variables, and then call these functions on all pages designated for processing.

for example, if we need to catch name and last variables on submit.. we can simply create a function like this.

function check_form(&$form_var,$type){
    $form_var = array();
    if(isset ( $_POST[''.$type.''])){

    $form_var['fname'] = $_POST['fname'];
    $form_var['lname'] = $_POST['lname'];

    return true;
    }
    else{

    ## do whatever you need to do  here

    }

    }

The function above will grab form variables on submit. Of course, you can easily modify it to your application. Just change the submit to delete or edit.

Secondly, we can create a helper function to help the above function. This helper function will be responsible for populating the new form on edit, and presenting the items to be deleted on your delete query.

function return_data($form_var){

echo $form_var['fname'];
echo '<br/>';
echo $form_var['lname'];
echo '<br/>';


}

in your edit and delete page, just add

include_once('functions.php');

## call the function like this

if(check_form($form_var,'edit'))
return_data($form_var);

The echo on the second function is just for demonstration..We can easily modify it, for the database update or delete..

something like this ...

 function return_data($form_var){

     $form_var['fname'];
     $form_var['lname'];

     return $form_var;
}

we can call it this way

if(check_form($form_var,'edit'))
$submitted_data = return_data($form_var);

echo $submitted_data['fname'];
echo $submitted_data['lname'];

Or we can populate a new form ..!This form will be process for the second time to update your database.

<form method="post" action="">
<input type="text" name="fname" value="<?php echo $submitted_data['fname']?> />
<br/>
<input type="text" name="lname" value="<?php …
veedeoo 474 Junior Poster Featured Poster

Hi,

How is the login system written? Is it in OOP or procedural.. If procedural, how does it check if the session exist? Is the application checks if the session exist, before setting a new one? OR if it does exist? How does the application validates if the new one is needed?

If it is written in OOP, the session should be located in the constructor and not anywhere in the page..

Something like this..

class login{

    public function __construct(){

    session_start(); 

    ## validate the existence

    ## destroy if needed..

    }

    ## validate or check if the session does exist for specific user

    private function check_session(){

   ## validate session here
    if(isset($_SESSION['username']))
    return true;


    }
    }

    ## destroy session

    private function destroy_session(){

    if(isset($_SESSION['username']) && (self::check_sesssion === true)){

   ## session definitel exist, you can destroy it here
   session_destroy();
    return true;

    }

}

## create the login function and make the visibility as public, because that is the method accessable from the outside.
}

You can write another comparator in the constructor to make sure the user has not log-out yet,and if it does, then the method destroy_session() must prevail by just calling it this way

    self::destroy_session(); 
veedeoo 474 Junior Poster Featured Poster

Hi,

could it be just a jquery issues? Because redering and instantiating a class occurs in the server side and have no dependencies on the browser types..

veedeoo 474 Junior Poster Featured Poster

Cool you got it sorted out, I am pretty sure people will find this helpful..

I was gonna say, it is the view causing the problem, because it is HMVC where the view is restricted to just following whatever the Controller desires.. pretty much the same concept as presentation abastraction control... or "Waiters are not allowed in the Kitchen" concept.

veedeoo 474 Junior Poster Featured Poster

I believe this is more of a javascript and html5 question. Try searching it on google, they've got tons of this already out there... multiple background HTML5

veedeoo 474 Junior Poster Featured Poster

Hi,

Are you running the script on the server or locally (on your desktop)? If so, you will need a developer server like XAMPP , easyPHP, or WAMP the choice is yours..

PHP cannot be parse by the browser alone.

If you are running it in NGINX http server, then the most common problem is in sites-available/default file.. Again, it all depends on how you set it up.

Please give us more info..

veedeoo 474 Junior Poster Featured Poster

I also prefer the associative array, as what Diafol already noted.

If you still prefer to have the object method, you can code it like this... very nice and simple

<?php

$json = file_get_contents('http://api.wunderground.com/api/658c0f8b283e4b98/tide/q/VA/Norfolk.json'); 

$data = json_decode($json);

foreach($data->tide->tideInfo as $item){
echo 'Tide Site :'. $item->tideSite .'<br/>';
echo 'Latitude : '. $item->lat .'<br/>';
echo 'Longtitude : '. $item->lon .'<br/>';
echo 'Units : '.$item->units .'<br/>';
echo 'Type : ' .$item->type .'<br/>';
echo 'Time Zone Name: '. $item->tzname.'<br/>';

}

If properly executed, the codes above should give us something similar to this

Tide Site :Little Creek NAB, Chesapeake Bay, Virginia
Latitude : 36.9117
Longtitude : -76.175
Units : feet
Type : tide
Time Zone Name: America/New_York

Example above will only parse the first item in the Tide array.. I you want to access the second item tideSummary , you will have to elevate the $data->tide having its own array.. something like this..

foreach($data->tide as $items){
## loop through the $item->tideInfo
## loop through all of them until you are getting the result you wanted

}
veedeoo 474 Junior Poster Featured Poster

Here is another hint.. If you want the movie details, change the codes to this..

foreach( $html->find('meta[name=description]') as $desc){

$movie_detail = explode("|", $desc->content);
echo 'Title : '. $movie_detail[2].'<br/>';
echo  $movie_detail[3].'<br/>';

$casts= explode(",", $movie_detail[4]);
echo 'Casts<br/>';
foreach($casts as $actor){
echo $actor.'<br/>';

}

}

The above codes should output similar to this

Title : Return To The Blue Lagoon (1991)
Director: William A. Graham
Casts
Cast: Milla Jovovich
Brian Krause
Lisa Pelikan
Courtney Barilla
Garette Ratliff Henson
Emma James
Jackson Barton
Nana Coburn
Brian Blain
Peter Hehir
Alexander Petersons

I hope this helps......I am in good faith that you were given the permission by the site owner,, otherwise it is not good parsing other site's content, because of the moral integrity defined by common principles.

veedeoo 474 Junior Poster Featured Poster

Cool :).

To parse this

Return To The Blue Lagoon, return to the blue lagoon, Return To The Blue Lagoon (1991), movies, watch movies, watch movies online free, download movies, watch free movies online, watch movies online, stream movies, watch free movies, stream movies online, streaming movies online, free online movies, new movies, drama movies

you need to change the foreach loop code above with this

foreach($html->find('meta[name=keywords]') as $element){
   echo $element->content.'<br/>';

   }

And to parse this

Watch Return To The Blue Lagoon Online | return to the blue lagoon | Return To The Blue Lagoon (1991) | Director: William A. Graham | Cast: Milla Jovovich, Brian Krause, Lisa Pelikan, Courtney Barilla, Garette Ratliff Henson, Emma James, Jackson Barton, Nana Coburn, Brian Blain, Peter Hehir, Alexander Petersons

You need to add this

foreach( $html->find('meta[name=description]') as $desc){
echo $desc->content.'<br/>';

}
veedeoo 474 Junior Poster Featured Poster

@Jkon,

Thanks for bringing that up..it is deprrecated since version 5.5.0.

So, to self-correct my response above, it should read like these...

In PDO, it has an equivalent object called FETCH_OBJ, where the column name is return as object's properties, similar to the now deprecated mysql function called Mysql_fetch_object.

$this_result = $statement->fetch(PDO::FETCH_OBJ);

## the same as above..
$this_result->Column_Name;

The same assumption can be placed on the mysql_fetch_array equivalent. The only difference is that in PDO this_result is also an object and here is why..

$this_result = $statement->fetch(PDO::FETCH_ASSOC);

## we can now iterate the object this_result

foreach($this_result as $column_name=>$values)
{
echo $column_name.' - '.$values.'<br />';
}

Still using it in OOP, the FETCH_ASSOC still make sense.. most importantly if it is for the template engine as shown by the updated example below..

public function someFunction(){

$this->query = "any_thing goes here";
$this->statement = $dbh->prepare($this->query);
$this->statement->execute();

return( $this->statement->fetch(PDO::FETCH_ASSOC));
}

The code above is a lot lighter than the codes written for the regular mysql in my previous example..

veedeoo 474 Junior Poster Featured Poster

to flip string in PHP, there is a PHP function called strrev . You can search it on google..

It should print the mirror image of any particular string..

something like this

Daniweb bewinaD

For the language characters, I believe wordpress is capable of storing characters of any language..

kindo commented: You can't use strrev for language translation +0
veedeoo 474 Junior Poster Featured Poster

Hi,

Might not be the best answer I can give, but I honestly believe Mysql_fetch_object returns object as in

$row->name_of_column

whereas mysql_fetch_array returns an array of data from particular query like ..

$row['name_of_column']

Although Mysql_fetch_object returns an object, it is pretty much convinient to use mysql_fetch_array in OOP. Just like this..

public function someFunction(){

$this_query = "any_thing goes here";
$this_result = mysql_query($this_query);
while ($rows = mysql_fetch_array($this_result))
{
  $res[] = $rows;
}

return $res;

}

The method above can store the output into an array, which can be then access by other methods or functions. This is crucial in passing the queried data to the template engine like Smarty or twig.

veedeoo 474 Junior Poster Featured Poster

Hi,

To make it work you will have to enable allow_url_include to on. However, there is a big security hole associated by allowing this to be on.

The best option you can probably use is the Simple Html Dom and the use of cURL.

Looking at your codes above and the source code of your target url, these does not exist anywhere in the page

echo $tags['author'];
echo $tags['geo_position'];

, and therefore your codes should be modified to this..

## include the simple html dom file
## assuming it is located in the dom directory
include_once('dom/simple_html_dom.php');

## write your simple cURL function

function useCurl($url){
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; MSIE 7.0; Windows NT 6.0; en-US)');
        curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,10);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        curl_setopt($ch, CURLOPT_AUTOREFERER, true);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        $output = curl_exec($ch);curl_close($ch);
        return $output;
        unset($output);
      }

 ## define your url variable
 $url = 'http://watch32.com/movies-online/return-to-the-blue-lagoon-2766';

 ## call the function above, and asigned the output to variable html_file
 $html_file = useCurl($url);

 ## use the str_get_html method from the simple html dom
 $html = str_get_html($html_file);

 ## iterate through the parse data --> meta with the content attribute
 foreach($html->find('meta') as $item){

   echo $item->content.'<br/>';

   }

If properly done, the script above should output

text/html; charset=utf-8
index, follow
Return To The Blue Lagoon, return to the blue lagoon, Return To The Blue Lagoon (1991), movies, watch movies, watch movies online free, download movies, watch free movies online, watch movies online, stream movies, watch free movies, stream movies online, …
veedeoo 474 Junior Poster Featured Poster

Try searching facebook documentation https://developers.facebook.com/. More likely, you will be able to find something similar for what you are trying to achieved. Just like twitter API, you will need an OAuth to be able for your application to work.

veedeoo 474 Junior Poster Featured Poster

Alternatively, you can also experiment with the PHP object called "Object Iteration" which can probably and specifically pull the first , middle, something in between, and the last item within an array. You can even count it first as suggested above and check the count pointer location, and if it is the it, do whatever you want to do with the it.

Don't have any sample codes right now, because I am currently busy with my JAVA project. Opening the PHP storage room where it resides in my brain will do me no good :).

veedeoo 474 Junior Poster Featured Poster

Hi,

Have u tried the official pods docs?

Should be no problems, if your wordpress version is supported.. pods only have a few methods to be considered.. The current release version of pods is 2.0 and it is supported from wordpress versions 3.4 up to 3.6.

Methods you need to be familiar with, before getting all of your fingers wet poddlings :)..

add()
data()
delete()
display()
export()
fetch()
field()
filters()
find()
form()
pagination()
row()
save()
template()
total()

I strongly suggest to temporarily disable the buddypress/multisite for the purpose of finding the conflicts in your script.

veedeoo 474 Junior Poster Featured Poster

Hi,

You will have to let us know your server environment in which this script is running. For example.. wampp, xampp, or something else..

Looking at your codes above, it is utilizing the gmail account credentials. If you are running this script in production server environment, you will have to acknoledge the gmail confirmation request by logging in to your gmail account and click on the hard to miss red box on top the page. Make sure you are confirming the IP address on your server and NOT someone-elses.

veedeoo 474 Junior Poster Featured Poster

Hi,

I am not a master nor closer to a master's bigfoot. However, did you try looking and searching for MySQL date arithmetic function? Once you find out what functions are available for your needs e.g. DATEDIFF, all you need is modify your initial query... that's all..

veedeoo 474 Junior Poster Featured Poster

LastMitch is perfectly correct.. Ask the author first..

To give you the general idea of what it is, it can be explain as simple as this..

$this->class()->the_method_of_this_class();

This process is also called chaining.. However, if it is not a class, but instead they are both methods of the same class, then the expression you have provided is perfectly wrong. Because $this->class() cannot be called within other class unless it is extended or it is an statically declared from somewhere. If they are both methods of the same class or the other is method of a parent class then the declaration should be somethin like this.

$this->method($this->method_1(),$this->method_2());

Which is simply an elaboration of nothing, but equal to

some_function($var_1,$var_2);
veedeoo 474 Junior Poster Featured Poster

hi,

Just want to add something..

This $OOO000000 is equal to fg6sbehpra4co_tnd..

The strings are encoded in such a manner that O is equavalent to 1 where as...

$OOO0000O0 is formulated dependent and referenced to 11100010

which is equavalent to 226 in human numbers..and this $OOO0000O0=$OOO000000{4} is actually equal to 228 in human numbers but it is 11100100 computer's own understanding OR it is just a mere E4 if it is expressed as HEX.

veedeoo 474 Junior Poster Featured Poster

Hi,

you can easily make this happen by creating two files. Assuming that the database have the following columns..

  • id + blob_content + ext +

first, upload.php

<?php

    ## mysql connector is in sample form. I strongly suggests to use PDO wrapper
    mysql_connect("localhost","db_user","db_password");
    mysql_select_db("blob_database");


    ## define form

    $form = '<form method="post" action="" enctype="multipart/form-data">

        <input type="file" name="image" /><br/><br/>
        <input type="submit" name="upload" value="Save Image" />
    </form>'; 


    if(isset($_POST['upload'])){
    ## check for the image extension
    $image_file = file_get_contents($_FILES['image']['tmp_name']);
    $image_file = mysql_escape_string($image_file); // use PDO::quote() instead. I am using this as an example only.

    @list(, , $img_type, ) = getimagesize($_FILES['image']['tmp_name']);

    if ($img_type == 3){
        $ext="png"; 
    }
    elseif ($img_type == 2){
    $ext="jpeg";
    }
    elseif ($img_type == 1){
    $ext="gif";
    }

$query = " insert into blob_table set blob_content = '".$image_file."', ext ='".$ext."' "; //PUt your query here and make sure the $ext has its own column..
mysql_query($query);

}

else
{

echo $form;

}


## show images that are already stored in the database.. show them as thumbs

## define your query

$get_imgQ = "select * FROM blob_image";
$this_Res = mysql_query($get_imgQ);

while($row =mysql_fetch_array($this_Res)){
        ?>
            <a href="imageLoader.php?id=<?php echo $row['id']?>"><img src="imageLoader.php?id=<?php echo $row['id']; ?>" width="100" height="100"></a>
        <?php
    }
?>

row['id'] is the id of your blob image in the database..

create another file called imageLoader.php

<?php

## filename :  imageloader.php
## connect to your database
mysql_connect("localhost","db_user","db_password");
mysql_select_db("blob_database");

## process the thumb request from the upload.php
$query ="select * from blob_image where id=".$_GET['id'];

$res = mysql_fetch_array(mysql_query($query));
$this_blob_data = $res['blob_content'];

## let the browser knows what it is
header('Content-Length: '.strlen($this_blob_data)); …
veedeoo 474 Junior Poster Featured Poster

This is pretty easy... all you have to do is make sure you have the proper php extension installed..

For text reading use.. fread function.

For PDF reading make sure you have http://www.foolabs.com/xpdf/about.html installed as php extension.
For DOC reading use this http://www.winfield.demon.nl/...

To read pdf file using php script, you can try something like this

$xpdf_location = 'usr/local/bin/xpdf__pdf_to_text'; //not sure, you will have to read the manual
## depending on your pHP installation.. usr/bin/ can also be valid.. it all depends on the actual installation

## define the location of the pdf file to be read
$pdf_file = 'uploads/somefile.pdf';

## execute the the xpdf as you wish

$thisPdf = @exec($xpdf_location, $pdf_file.'_');

## for debugging purposes remove the error  (@) supressant above..

print($thisPdf);

## for the Doc
$doc_location = 'uploads/somedoc.doc';

$thisDoc = @exec('docReader_location','docFilename');

print($thisDoc);

For additional reading, make sure to search for error reporting on PHP triggered exec command or shell exec.. this should be able to give you a line by line error report just in case something is not working properly in the back-end.

veedeoo 474 Junior Poster Featured Poster

Larry Singleton will really hate me by getting away without the use or foreach loop :) :).. It is all about strategy Larry lol .....

veedeoo 474 Junior Poster Featured Poster

Hi,

Here is a sample script that can be easily modified to your needs.. Again, you need to test this several times and MUST provide the sufficient security measures for the form processor method get_formData(&$formVars)

First, create a new php file called Simple_Class.class.php and and paste codes below to this file.

<?php

## written by veedeoo 2013 => humbled and honored to be able to help Daniweb.com members
## there is no warranty nor guarantee given to this script
## Copyright announcement must remain intact.
## for further discussions must post question to daniweb forum


## we use interface for future expansion
/*
*@interface prepare database credentials
*
*/
interface db_credentials
{
   const DB_HOST = 'localhost';
   const DB_NAME = 'dbname';
   const DB_USER = 'db_user';
   const DB_PASS = '';
}

/*
*@simple_class class to do the heavy lifting
*@implements class uses the db_credentials
*/

class Simple_Class implements db_credentials{

    private $db;

    public function __construct(){

    }
## simple PDO interface just in case you need one
/*
*@db_connect method
*creates a PDO instance
*validates connection
*/
    private function db_connect(){
        try{
        $this->db = new PDO('mysql:host='.self::DB_HOST.';dbname='.self::DB_NAME.';charset=utf8', self::DB_USER, self::DB_PASS ,array(PDO::ATTR_PERSISTENT => true));
        $this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT);
        return true;
        }
        catch(PDOException $err) {
                        return false;
                        die('OOPS Database Connection Problem detected: ' .$err->getMessage());
                    }
        }
/*
* if you need to expand the PDO method above, do so by creating a new pdo function below
*/

## A simple form processor
## Warning! this is not a sanitized variables suitable and not suitable for database..

    public function get_formData(&$formVars){
        $formVars = …
veedeoo 474 Junior Poster Featured Poster

Hi,

jUst to help you out on how to handle those switches gracefully. Just to let everybody know that there is nothing wrong with php switch function. However, in medium to large applications, it will become time consuming to write cases if hundreds of pages are involved. MVC framework design does offer the solutions and flexibilities to this conundrum, but that is not my objective here.. I just want to share a simple solution or rather an alternative way of doing switches..

ok... Let's do it.... First, I sincerely apologize for extra brackets on my sample usage ...I always get back to my old habit of parenthesizing every thing a little too much. You can develope this habit, if you hang around with Math and Physic geeks a lot ( excluding myself of course :)).

here we go.. the simplest and the shortest I can possibly think of..

function include_page($page){

$this_page = $page.'.php';
return(file_exists($this_page) ? true : false );

}

simple usage example ...

 if((isset($_GET['id'])) && (include_page($_GET['id']))){

    include_once(($_GET['id'].'.php'));

}
else{

   include ('include/content.php');
   include ('include/sidebar.php');

   ## if there is  no default page to include for false evaluation, then it should be set to false

    //false;
}

Simple function above can be modified to accept file extension ,dir , and even the GET[key] can be use as parameters if you want.

veedeoo 474 Junior Poster Featured Poster

Hi,

I have no intension of rediculing your script, but it worries me.. if ever this application is adopted to production server.

Don't worry much about the update for now, that is a pretty easy thing to do. Focus on, or at least give it some few minutes of thoughts on how your script will function if given a simple security evaluation..

most importantly, this part of your script,

$email=$_POST['myusername'];
$password=$_POST['mypassword'];
$query="select * from consumer where email='$email' and password='$password'";

So, if we type this values for myusername and mypassword.. we should be able to extract pretty much all of the members in our database..

    'anyusername' OR 'yx'='yx'

the same for our pass word

     'anypassword' OR 'yx'='yx'

by typing those hacks in your form, the php script will output all of our members stored in the database.

try running this on your phpmyadmin

SELECT * FROM `consumer` WHERE email='anymember' OR 'yx'='yx';

Should we be concern about the update query at this stage of our script? NO, we should fixed the security hole and then move on to much simpler problems..

The point I am trying to make here is that, it does not really matter if this is an school project, where the Professors doesn't really care much about security because of isolated environment. However, codes we write while in academic classrooms are the foundation of all the codes we are going to write in the real world.

veedeoo 474 Junior Poster Featured Poster

ERROR spotted already.. Admin.class.php

in the constructor, you will need to add this to connect, fill in your database credentials....

$this->db->Connect($host, $user, $password, $database);
veedeoo 474 Junior Poster Featured Poster

Hi,

Too many other ways of doing this. We can make it at lot simpler, but I don't like auto loading whenever a db connector is involve, I rather write it in basic class and then deliver the instance of the class by Singleton.

kinda like this... you should convert the mysql to mysql PDO.. I don't have my PDO reference, so I will have to do it in the old ways which I can remember easily.

You must remove the error announcement or modify it to something else to prevent actual error broadcast on failed attempt. Please take note of any syntax errors... I don't have the chance testing it....

This is pretty much the semi-model of the application. If you are to use the pure MVC design pattern the Admin.class.php should be included in the model, and the instantiator is the helper to the model, after the controller sort all the url requests and acted with the proper routing response.

WARNING! CODES BELOW ARE NOT TESTED.. IT CAN, OR IT MAY HAVE SOME ERRORS ON IT. IT is provided as a guidelines only and NOT intended for production server, until all security issues are considered.

filename: Database.class.php

<?php

    class Database{

    private $results, $inserted_id, $connection_id;

    public function __construct(){
    }

    public function Connect($host, $user, $password, $database) {
        $this->connection_id = @mysql_connect($host, $user, $password) or $this->db_error(mysql_error()) ;
        @mysql_select_db($database) or $this->db_error(mysql_error()) ;
        $host = '';
        $user = '';
        $password = '';
        $database = '';
    }

    /*
    *@ method query :  prepare the database …
veedeoo 474 Junior Poster Featured Poster

you can also try this... copy and save anyname.php. Upload to the public directory of your server or the location where the upload script resides.

<?php 

phpinfo(); 

?>

Direct your browser to this file e.g. yourdomain.com anyname.php. Let us know these values

  1. Server API = this could be either fast cgi, or apache module
  2. Loaded Configuration File = this is the php.ini file currently being utilized by your server, and it is responsible for practically all php related restraints
  3. post_max_size= newly installed php is normally given a default value of 2m .. I would guess in your case it is only set to 50M
  4. max_execution_time = this is the time alloted to your php applications before the server will terminate it regardless if upload is finished or not, or the script has been successfully executed or not. You may want to change this to something around 1800.. you can change this value to your needs.
  5. upload_max_filesize = What ever value you have given to the post_max_size must be given to this.

If your server API is apache module, then you will have to edit the php.ini file in the loaded configuration file location. However, there is another way of tweaking the upload limit in apache module API. This can be done by adding simple entries on .htaccess file.

Else if, your server API is a fast CGI or other derivatives of CGI, then a php.ini additional settings or modifications can be be uploaded in the directory(OR UNDER YOUR …