veedeoo 474 Junior Poster Featured Poster

I honestly believe, you can use composer autoloader and symfony class loader and http-foundation.

Supposed we have our development environment in localhost/myapp/, and we are running xampp or wampp on windows. We can easily solve the autoload problems in two ways. This is just an example. If you will running this on linux, then just add $ in front of the composer command that simple

First install the composer..,
1. Test the composer after installation and make it is working. Open the command prompt, and then type

composer

it should return the version and info. about your composer version.

  1. Now let us create our simple application using composer autoload. Create the directory called myapp in your xampp/htdocs/myapp. Inside the myapp directory create another directory called application.

  2. Open your text editor or any suitable source code editor and then paste codes below, and save as composer.json

    {
    
    "require": {
        "symfony/class-loader": "2.4.*@dev",
        "symfony/http-foundation": "2.3.*@dev",
        "phpunit/phpunit": "3.7.*",
        "swiftmailer/swiftmailer": ">=4.2.0,<4.3-dev"
    },
    
    "minimum-stability": "dev"
    }
    

I added some common vendors found on PHP MVC framework like Laravel, PPI and Kohana. I mean this is an actual build if you want to create your own framework.

I also added phpunit for you to experiment. If you will be applying for a 6 figure job as a developer, you must know all this, otherwise you will be debugging other people's codes for a long long time.

  1. Go back to your command prompt and type

    cd c:/xampp/htdocs/myapp
    

once you are …

veedeoo 474 Junior Poster Featured Poster

have you tried response.redirect ?

I haven't coded in C# and VB for a while, but I think that might work for you. I don't remember the proper syntax, but I would guess it could be something like this.

response.redirect('yourpage.php?value=SomeValue');

Another thing is the ListItem control though? Is your application able to use the html form..?

veedeoo 474 Junior Poster Featured Poster

Like what Pritaeas and Cereal said, Laravel is well coded from the beginning to end. Laravel is also built upon Symfony Components without the Twig. I have seen questions on the web asking which one is better Symfony or Laravel. This question seems to be valid and yet Ignorant and extremely mal-informed. Laravel will not exist without the Symfony components and foundation. The founder of Laravel even acknowledge this, because of one of the person at the convetion asking him, if he want to close Symfony's door. His response was " We would never existed, if Symfony does not exist". So, what this means is that, the dependency of of Laravel's core to symfony is pretty high.

So, to add answer to your question, I would choose Laravel over CI, because it uses components that are regularly updated.

Here are the framework questions that are pretty confusing, unless you are extremely active in PHP community. I mean active at the core where all of the changes and developments are announce.

CakePHP -- Pretty much on its own, except for some contributed plugins and modules. Composer ok

Zend -- Pretty much on its own, but have enough resources to lead the framework game. No matter what convulated opinions we picked up from the web, Zend is not going away. They are pretty much part of the governing bodies that drives the evolution of PHP. Unless, our 3rd grade teacher who barely read technology news, said it is not true. Can take …

veedeoo 474 Junior Poster Featured Poster

Hi,

I don't know if this will help you, but this is the representation of your example above.

css credit goes here.

Modulu is really good in doing the odd and even rows, but when you need to be specifically want to plug something between the iterated items, a simple for loop will probably do the job.

As I already mentioned.. codes below represents you sample html above. Feel free to experiment with it. Just make sure that the loops has ends, otherwise it will go infinite..

<style type="text/css">
table.gridtable {
    font-family: verdana,arial,sans-serif;
    font-size:11px;
    color:#333333;
    border-width: 1px;
    border-color: #666666;
    border-collapse: collapse;
}
table.gridtable th {
    border-width: 1px;
    padding: 8px;
    border-style: solid;
    border-color: #666666;
    background-color: #dedede;
}
table.gridtable td {
    border-width: 1px;
    padding: 8px;
    border-style: solid;
    border-color: #666666;
    background-color: #ffffff;
}
</style>

<table class="gridtable">
    <tr>

<?php

$col = 5; $i = 0; $x = 0; $y = 0; $z = 0;
$tdArr = array('Data One', 'Data Two', 'Data Three');

for($z = 1; $z <= $col; $z++){

## echo your  table cols.

        echo '<th>Col '.$z.'</th>';


}

 echo '</tr><tr>';
                ## for first row 
                for($i = 1 ; $i <= $col; $i++){
                echo '<td>'.$tdArr[0].' '.$i.'</td>';
                    if($i == $col){
                    echo '</tr>';
                    }}

        ## second row
    echo '<tr>';
            for($x = 1 ; $x <= $col; $x++){
    echo '<td>'.$tdArr[1].' '. $x .'</td>';
        if($x == $col){
        echo '</tr>';
        }}

        ## third row
    echo '<tr>';
            for($y = 1 ; $y <= $col; $y++){
    echo '<td>'.$tdArr[2].' '. $y .'</td>';
        if($y == $col){
        echo '</tr>';
        }}          
?>

</table>
veedeoo 474 Junior Poster Featured Poster

I also think $_SERVER['REQUEST_URI'] is a lot nicer thing to do. Most frameworks uses this approach that is why there is no big chunk of .htaccess file in CI but deny from all.

veedeoo 474 Junior Poster Featured Poster

here is a clean report example

Attacks details
SQL Injection
No vulnerabilities found
Blind SQL Injection
No vulnerabilities found
File Handling
No vulnerabilities found
Cross Site Scripting
No vulnerabilities found
CRLF
No vulnerabilities found
Commands execution
No vulnerabilities found
Resource consumption
No vulnerabilities found
Htaccess Bypass
No vulnerabilities found
Backup file
No vulnerabilities found
Potentially dangerous file

command used

cd c:\wapiti\src

python wapitiy.py http://localhost/register.php -f html -o registrationformtest

the report will be available for viewing as html page at wapiti\src\registrationformtest\index.html

test login script

python wapitiy.py http://localhost/login.php -f html -o loginformtest

test search form processor

python wapitiy.py http://localhost/search.php -f html -o searchformtest
veedeoo 474 Junior Poster Featured Poster

Do as suggested above... Install python 2.7.x, and download wapiti as suggested by sinhaksaurabh.

Download python here, Download wapiti here .

  1. If running this on windows, Extract the Wapiti src directory in in C:\wapiti.

  2. Open the windows command prompt, or the command prompt python.

  3. type python on the prompt. It should give you the version of python installed on your system. If you don't see similar to this

    Python 2.7.5 (default, May 15 2013, 22:44:16) [MSC v.1500 64 bit on win 32

the python installation failed.. you must try re-intalling it.

  1. Follow the instruction on how to use the wapiti.

Example of usage: Windows

cd c:\wapiti\src 
# python wapiti.py http://yourDomainDotCom 

You can also define the method of attack such as xss:get , exec:post and all. Just add the this option after the command ( shown in the documentation).

-m "-all,xss:get,exec:post"

And make sure to add -n the number of urls you need to test, otherwise, it may go on infinite loop.

Sample usage added after the first and second commands

-n 30

Don't forget to set the report type in the end..

veedeoo 474 Junior Poster Featured Poster

it really depends on your system.If you are running xampp on windows 8, then just look at the php info. of your xampp installation and look for the compiler used on your version. Applications for windows are compiled with either VC9, VC11 .

The latest ffmpeg compiled by sergey89.ru was VC9, so this may not be compatible for the latest php version 5.5.3 on xampp version 1.8.3 with PHP version 5.5.3. However, you can probably use the older xampp release 1.8.2 which has php 5.4.x and I think this particular version was compiled in VC9.

Don't take my words on this.. I am just pulling these fragmented info. out of my head, and sometimes my memory does not serve me very well.. You need to do some searching on the subject matter.

veedeoo 474 Junior Poster Featured Poster

Will you be kind enough to at least let us know, what were those steps? Is it these steps as described or is it something else?

veedeoo 474 Junior Poster Featured Poster

if your PHP is not compile with ffmpeg-php, then you can call the exec like this.

## define the location of your ffmpeg somewhere in drive C: . Assuming that the location of ffmpeg binary file is located in drive c.

$ffmpeg_loc = 'c:/ffmpeg_test/bin/ffmpeg.exe';

## define options for your mp3 file

$mp3_options = '-acodec libmp3lame -ab 128k';

## if you are running the latest ffmpeg with volume support, you can it like this.
$mp3_options = '-vol 256 -acodec libmp3lame -ab 128k';

## define the input
$input = '10001_pre.wav';
## define the output name and location

$output = 'file.mp3';

## assemble everything and then execute.
exec($ffmpeg_loc.' -i '.$input $mp3_options $output );

Compile means that you have the codec dll files for the PHP, and the ffmpeg php extension. Else, use the above suggestions.

veedeoo 474 Junior Poster Featured Poster

Looking at your codes, the variable matchtag should return "quote" and backhash returns 'standard'.

veedeoo 474 Junior Poster Featured Poster

Ok,... let's take care of this puppy once and for good.. I normally assign everything as an array, because it saves time and variables are easy to track and update. So, this example application will not be the same as what we could find on the web. By doing the same construct, it will be a lot easier to upgrade your CI with Smarty, Twig, or TinyButStrong package in the future.

controllers/page.php

<?php
class Page extends CI_Controller {

public function __construct(){
parent::__construct();
$this->load->helper('url');

}
public function index()
{
## define the location of your css directory in reference to the application directory

$data = array(
        'style' => base_url().'assets/css/style.css',
        'connection' => base_url().'assets/images/connection.jpg',
        'collaboration' => base_url().'assets/images/collaboration.jpg',
        'solution' => base_url().'assets/images/solution.jpg',
        'connectionUrl'=> base_url().'index.php/connection/',
        'collaborationUrl' => base_url().'index.php/collaboration/',
        'solutionUrl' => base_url().'index.php/solution/'

        );

$this->load->view('homepage', $data);
}

}

views/homepage.php

    <a href="<?php echo $connectionUrl; ?>"><img src="<?php echo $connection; ?>"></a>
<a href="<?php echo $collaborationUrl; ?>"><img src="<?php echo $collaboration ?>"></a>
<a href="<?php echo $solutionUrl; ?>"><img src="<?php echo $solution ?>"></a>

controllers/connection.php

class Connection extends CI_Controller {

public function __construct(){

 parent::__construct();
 $this->load->helper('url');

}
public function index(){



 $data = array(
            'connection'=>'Type your connection content here'
            );

 $this->load->view('connection',$data);


}

}

controllers/collaboration.php

class Collaboration extends CI_Controller {

public function __construct(){

 parent::__construct();
 $this->load->helper('url');

}
public function index(){



 $data = array(
            'collaboration'=>'Type your collaboration content here'
            );

 $this->load->view('collaboration',$data);


}

}

controllers/solution.php

class Solution extends CI_Controller {

public function __construct(){

 parent::__construct();
 $this->load->helper('url');

}
public function index(){



 $data = array(
            'solution'=>'Type your solution content here'
            );

 $this->load->view('solution',$data);


}

}

views/connection.php

<?php echo $connection;?>
veedeoo 474 Junior Poster Featured Poster

are sure the column num exists in your database..or is it id?

also, if you don't mind, you can refactor your codes above to something less cluterry..

echo '<table width="85%" align="center" border="1">';
echo '<tr><td>Settlement Number</td><td>FirstParty</td><td>SecondParty</td><td>Email</td><td>Phone</td><td>Created Date</td></tr>';

while($row=mysql_fetch_array($sql))
{ 
echo '<tr><td><a href="home.php?num='. $row['num'].'">'. $row['num'].'</a></td>
<td>'. $row['firstparty'] .'</td>
<td>'. $row['secondparty'] .'</td>
<td>'. $row['partyemail'] .'</td>
<td>'. $row['phone'] .'</td>
<td>'. $row['idate'] .'</td></tr>';
}
echo'</table>';
veedeoo 474 Junior Poster Featured Poster

these were wrong.. I didn't even realized it, until when you brought if up.

'connectionUrl'=>base_url().'index.php/connection/';
'collaborationUrl' => base_url().'index.php/collaboration/';
'solutionUrl' => base_url().'index.php/solution/';

correct way

'connectionUrl'= base_url().'index.php/connection/';
'collaborationUrl' = base_url().'index.php/collaboration/';
'solutionUrl' = base_url().'index.php/solution/';

You need to create a new page called connection, collaboration, and solution , in order for it to work.

You probably don't even need to route it. As long as you have pages in the controller directory, the CI autoloader will look for it.

veedeoo 474 Junior Poster Featured Poster

change these

    prime(51)
    prime(11)

to

    determine(51)
    determine(11)
veedeoo 474 Junior Poster Featured Poster

Hi,

There is no simplest form of a solution to a problem, without going into the basics.

I never crossed past the PHP forum, but I just did this time. It is not that I am not capable of writing codes in Ruby, but it is because I am so darn lazy.

My question is, what good will it brings you, if I or someone ever give you the codes that will satisfy your school homework questions?

Here are the stages of Ruby that I have to go through, while learning the language. Believe me it is not that hard really... at least for me. I just have to remind me about all these things.

  1. Learn the form formatter.

    print "What's your name?"
    first_name = gets.chomp

  2. Learn the operators like so..

    Addition (+)
    Subtraction (-)
    Multiplication (*)
    Division (/)
    Exponentiation (**)
    Modulo (%)

to multiply

1 * 2

to add

1 + 2

to exponentiate

2 ** 2
  1. Learn sring function . Remember pretty much everything in Ruby are objects.

to get the length of a string

"mystring".length

"mystring".upcase

# this will create a  lower case of MYSTRING
"MYSTRING".downcase
  1. Learn the naming conventions

    my_localvariable = "hello Ruby"

    this is legal in Ruby, but you must stay within the norms

    @my_localvariables = "hello Ruby"

  2. Master the control flow as you move along

    print "Type a number: "
    num_typed = Integer(gets.chomp)

    if num_typed > 0

veedeoo 474 Junior Poster Featured Poster

Stay away from all these troubles.. install an XAMPP or equivalent. 5.3.27 php version is pretty old. Use the latest or at least 5.5.1. The current stable release version as of today is 5.5.3

If you will running an application that is not version 5.5.3 capable, stay with the 5.3.27.

regular MySQL queries are no longer supported in 5.5.3 ., If you run an older script in this environment you will end up getting a mysql support has been deprecated.

PHP 5.5.3 allows you to take your application to the latest advancement in PHP including a much better password hasher.

If you don't like XAMPP there is also a BITNAMI WAMP Stack bundled with phpMyAdmin, SQLite, Varnish, ImageMagick, ModSecurity, XDebug, Xcache, OAuth, Memcache, FastCGI, APC, GD, OpenSSL, CURL, openLDAP, PEAR, PECL, AND most importantly, it comes with Zend Framework, CodeIgniter, Symfony, Laravel, smarty and many others. I am currently using Bitnami Python in parallel with the XAMPP..

I like xampp, because it comes with mercury mail and tomcat for my JAVA servelets projects.

veedeoo 474 Junior Poster Featured Poster

these are good for the images and the css files..

 $data['style'] = base_url().'assets/css/style.css';
$data['connection'] = base_url().'assets/images/connection.jpg';
$data['collaboration'] = base_url().'assets/images/collaboration.jpg';
$data['solution'] = base_url().'assets/images/solution.jpg';

for the pages like connection.php, you can difine them like so..

'connectionUrl'=>base_url().'index.php/connection/';
'collaborationUrl' => base_url().'index.php/collaboration/';
'solutionUrl' => base_url().'index.php/solution/';

by doing so, you don't even have to write a route for those pages..except when pagination is utilized.

connection.php coltroller page example

Class Connection extends CI_Controller {

    function __construct() {
    parent::__construct();

    ## use only the model part if the content of the connection.php are coming from the database. Else, just leave it as is
    //$this->load->model('connection_model');

    $this->load->helper("url");

    }

    public function Connection(){

    //give this function a job

    //assign the return of this function to the view

    }

    }

Do the same to the remaining files.. Always create a model if the content is coming from the database..

CI naming standard for the model is similar to the controller's but it is a Pear style and not the Pascal style or camel style. This has to be named as connection_model.php

class Connection_model extends CI_Model {

public function __construct()
{
    parent::_construct();
    ## must load database module
    //$this->load->database();

}

public function someFunction(){

}
}
veedeoo 474 Junior Poster Featured Poster

Hi,

I strongly suggests to do your counting in the business logic side and not on the presentation side.

Another thing that I am not very clear on your question is that: Are you trying to count the failed submission/s? If so, then you don't loop over the number of failed submission, you need the SUM of an array, NOT increment by loop. You can use session too -> maybe??

****option 1: ****
Assign the failed submission in session, and pass this value to the template side. If a previous session is set, then add one to the current one re-assigning or refreshing the session and giving it the value of old + New.

option 2:
PHP has a function called array_sum(), and it can also work pretty well for your purpose. For example, using the integers you have provided above, we can derive the sum by simply using array_sum

$arr = array(
            1, 
            2, 
            3, 
            4);

$smarty->assign('number',array_sum($arr));

Also, it is a common practice in smarty-> Whenever there is a form in the presentation side, **no cache ** must be use. What this means is that the form tag should be wrapped with no cache.

Security Implications:
IN CASE the cache function is turned on... it will be a desaster because the last information inputted in the form are cached until a new one is created as the old one expires. The security concern here is that, those cached information can be username, credit card number, …

veedeoo 474 Junior Poster Featured Poster

define the image directory and pass it on to the view side..

$data['images'] = base_url().'assets/images',

you can also send this to the header if you want, the view files can then use the url

<div id="products">
<a href="connection.php"><img src="<?php echo $images; ?>/connectionImage.jpg" /></a>

</div>
veedeoo 474 Junior Poster Featured Poster

also, if you really want to put your css directory within the same level as the application directory, we can code the controller like this

<?php

class Page extends CI_Controller {

public function __construct(){

parent::__construct();

## load the url helper object
$this->load->helper("url");
}

public function index(){

## define the location of your css directory in reference to the application directory

$data['style'] = base_url().'assets/css/style.css',

$this->load->view('homepage', $data);
}
}

now your style.css can load the background image using this ../images/indonusa3.jpg

The homepage page should have ...

<head>
<link href= "<?php echo $style ; ?>" rel="stylesheet" type="text/css" media="screen">
</head>

That should do it for you...

veedeoo 474 Junior Poster Featured Poster

Learning them both would not hurt.

veedeoo 474 Junior Poster Featured Poster

between these two,

    $route['default_controller'] = "page";
    $route['404_override'] = '';

add $route['page'] = 'page'; like

    ## this where it all begins
    $route['default_controller'] = "page/view";

    ## this will make your page visible
    $route['page'] = 'page';

    ## this will catch anything
    $route['page/(:any)'] = 'page/view/$1';

    ## this will route to 404 for pages that don't exist in page namespace
    $route['404_override'] = '';
veedeoo 474 Junior Poster Featured Poster

There should be no .php file extension. the loader will take care of it for you..

veedeoo 474 Junior Poster Featured Poster

I made a correction on my original response.. I got carried away hitting the gt

it should read

     <?php $this->load->view('includes/navigation'); ?>
veedeoo 474 Junior Poster Featured Poster

we cannot do that in CodeIgniter and other MVC frameworks... The right way of doing this is by using the $this->load->view syntax.

For example, if you want the navigation included in the header, as long as the includes directory is inside the views directory, the autoloader will look for the file defined as parameter..

Example head.php, wants to include the includeds/navigation.php . The proper syntax or construct for it will be..

filename: head.php

    <?php $this->load->view('includes/navigation');?>

Say, you have left and right pages for the main page, just do the same..

<?php $this->load->view('includes/left');?>
<h2> This is my middle div content</h2>

<?php $this->load->view('includes/right');?>

In MVC the syntax rules always follows the PSR,.. simirlarly, symfony and Zend takes it to the next level, a PSR, composer type autoloading e.g.

  includes\navigation\navigation

which translate to the directory, namespace and the class name of the navigation file.

veedeoo 474 Junior Poster Featured Poster

I totally agree with Dani. All things can be either assigned in your controller or inherited from the view pages...

On your previous questions, there was some controller codes that look similar to this..I don't remember them exactly, but I would guess it was something like this.

public function index()
{
    $data['news'] = $this->news_model->get_news();
    $data['title'] = 'Some title';

$this->load->view('templates/header', $data);
$this->load->view('news/index', $data);
$this->load->view('templates/footer');

So, if we want the navigation items on the header file, then put it there, If it is coming from the database, then load it through the controller..

for example,. we want a navigation item for the page..

 public function index()
{
    $data['news'] = $this->news_model->get_news();
    $data['title'] = 'Some title';

    ## assign things going for the headers
    $header['home'] = 'view/home';
    $header['about'] = 'view/about';
    $header['register'] = 'view/register';
    $header['title'] = 'Title';

$this->load->view('templates/header', $header);
$this->load->view('news/index', $data);
$this->load->view('templates/footer');

The file templates/header.php can use the item, just by

 <a href="<?php echo $home;?>">Home</a>
  <a href="<?php echo $about;?>">About Us</a>

You can also asign the base url for specific controller files like

  $config["base_url"] = base_url().'index.php/news';

MVC frameworks are very powerful tool, you just have to know their basic consruct.. otherwise you will be lost..

Once you've learned one of them, pretty much the rest are not too hard to understand, because they are almost all the same. Except, for the symfony it has some wicked derivatives that really need some close attention and learning.

By the time, you get into pagination with CI, you probably expert in routing all …

veedeoo 474 Junior Poster Featured Poster

Hi,

The php.ini values are not enough.. it will just time out on you.. on the average of 60MB to 100MB file transfer the recommended settings are about

max_input_time = 1000
max_execution_time = 1000
upload_max_filesize = 200M
register_argc_argv = On
post_max_size = 200M

Don't run the script until both of the php.ini files on both servers are properly set.

You let me know when your done, and I will write a simple script than can transfer up to 1gb server to server without the use of FTP or any of those crap they overly hyped. 1gb in less than 5 minutes server to server. This is the script I used to move server to server. I don't really use the cpanel transfers.. just open the script on the browser, and the files are on its way..

veedeoo 474 Junior Poster Featured Poster

Hi,

To be able to use sqlite, you will have to use PDO wrapper. The most basic PDO approach can be something similar to this..

try {

$conSql= new PDO("sqlite:PathOfYourDatabase");

}
## catch exception right after the try
catch(PDOException $error){
echo $error->getMessage();
}

The linked script above is old, I am pretty sure it will have difficulty thrieving in the latest PHP environment. For example, looking at the class itself it is more of a backward compatible to the older version of PHP. So, the best way to make the script compatible to what you are trying to achieved is to make an upgrade.. In this part of the code,

class FGMembersite
{
var $admin_email;
var $from_address;

var $username;
var $pwd;
var $database;
var $tablename;
var $connection;
var $rand_key;

var $site_name; // this is from the salt.php
var $randK; // this is from the salt.php
var $userType = false;
var $userSess = null;
var $user;


var $error_message;

//-----Initialization -------
function FGMembersite()
{
    $this->sitename = $this->site_name;
    $this->rand_key = $this->randK;
}

function InitDB($host,$uname,$pwd,$database,$tablename)
{
    $this->db_host  = $host;
    $this->username = $uname;
    $this->pwd  = $pwd;
    $this->database  = $database;
    $this->tablename = $tablename;

}

You may want to upgrade it to something like this..

class FGMembersite{

## if you want you can itimize them nicely..

private $admin_email, $from_address, $username, $pwd, $database, $tablename, $connection, $rand_key, $site_name, $randK, var $user;

## like these
private $userType = false;
private $userSess = null;
private $error_message;


public function __construct(){

## we can create an instance of the PDO in …
veedeoo 474 Junior Poster Featured Poster

After having my eyes refreshed from looking at too many codes, I just noticed that your controller is missing lots of stuffs. For example, the contructor is missing. There should be a constructor here if you want to initialize the news_model and use its method called set_news().

Something like this

public function __construct()
{
    parent::__construct();
    $this->load->model('news_model');
}

because your original codes has this

 $this->news_model->set_news();

and even this, you have pointing into the view/news directory

 $this->load->view('news/create');

so, if your view files for the pages controller is located in the views/pages, then you will have to adjust everything including the routes.php .

It is also recommended to have a model class for your application. It can be called as pages_model.php or news_model the choice is yours. However, I highly recommend for you use the pages_model.php, because this will eliminate some the potential naming collision in the future.

veedeoo 474 Junior Poster Featured Poster

can you show us your config/routes.php? e.g

$route['pages/create'] =  'pages/create';
veedeoo 474 Junior Poster Featured Poster

Hi,

I totally agree with Broj1. To answer your 2nd questions, there are no definite numbers of ways, it all depends on what will comes up on the black box. Any vulnerabilities found on the website are tested if it can be use to make a bigger splash.

About the MD5 hash this has been exposed and abused too many times already, even the so called sha is getting closer to be exposed in a broad daylight, but I will take sha rather than using the MD5. What is new in PHP 5.5.0 -> 5.5.1 is the stronger hashing called password_hash. For now, I think it will be nice and tight because it is an algorithm option as parameter.

Below is a simple class, I just jotted down on my notepad++ to test the new password_hash, but when I began to test it, I've realized that I was running PHP 5.4.7 on my localhost. So, I retracted back and added the SHA hashing method for backward compatibility. I was going to use this as a replacement for the kohana password handler, or in sentry 2, because I don't really believe in open source when it comes to hashing. I always have doubts and too suspicious that maybe someone left the back-door open.

I used MD5 here just for the purpose of creating salt and key. You can modify the script below to your own taste, it is just an skeleton for testing, and not intended for production server..But …

veedeoo 474 Junior Poster Featured Poster

look for the IP of the computer where the php script is running, click on the network preferences. Record this IP addresss, and move to the remote computer, and type http://ip_address_here/signup.php .

veedeoo 474 Junior Poster Featured Poster

hi,

If you want to save js file with php extension, then it should be just like this..

 function _(x){
    return document.getElementById(x);
    }
    function toggleElement(x){
    var x = _(x);
    if(x.style.display == 'block'){
    x.style.display = 'none';
    }else{
    x.style.display = 'block';
    }
    }

save it as main.js.php . That should do the trick.. joomla uses this a lot it think., but I am sure one of those big content management uses php file extension for the javascript file..

veedeoo 474 Junior Poster Featured Poster

Hi,

I think you are making codeIgniter more complex than it should. What is happening in your code is that you are trying iterate on an array that codeIgniter is not aware of.

If the filenames of the pictures are stored in the database, then you should build your model, if not then the controller method gallery_show should have to read the upload directory and then pass the results on the view.

if the filenames are in the database, then your model should look something similar to this..

Here is an example model class for the data stored in the database...

class Upload_model extends CI_Model {

## create a constructor method

public function __construct(){

## initiliaze the database connector from the library
$this->load->database();

}

## create the query method that will deliver the result to your controller

public function get_photos(){

## I will use the standard query here to prevent any further confusion.

$thisQuery = "SELECT * FROM photos";
$query = $this->db->query($thisQuery);

return $query->result_array(15);


}

}

The result_array method is capable of taking the limit parameters.

Now that we have our model, we create our controller

class Upload extends CI_Controller {


public function __construct() {
    parent::__construct();

    ## we need to load the url helper, just in case the router 
    ## becomes really excited in routing everything back to the application directory

    $this->load->helper("url");
    $this->load->model('upload_model');

}

public function index(){
    $data['photos'] = $this->upload_model->get_photos();
    $data['url'] = base_url();

     $this->load->view('gallery', $data); 


}

}   

Your view file gallery should look something similar to this.

<?php …
veedeoo 474 Junior Poster Featured Poster

ok, I found the site.. I couldn't remember it a moment ago. Here are the construct for the oracle DB .

veedeoo 474 Junior Poster Featured Poster

Hi,

I think that is pretty much possible and can be done. There is an ORM for Kohana called Leap ORM , which I believe is capable of handling different types of DB.

veedeoo 474 Junior Poster Featured Poster

is it really must have to use the FULLTEXT mysql function to be able to search? The reason I am asking is that FULLTEXT is less forgiving than the LIKE function.

What I am trying to get here is that..this

SELECT * FROM chardonnay WHERE MATCH name AGAINST('%".$find."%')

must have at least 50% consistency on the column name? So, for chardonnay and CHARDONAY it may be represented as inconsistent. I am not positively sure about this, but you can double check about it in the oracle website under MySQL.

You can experiment with this query if you want just to compare the results..

SELECT * FROM chardonnay WHERE name LIKE('%".$find."%')

If you still want to use the FULLTEXT function at least you must give it some slacks..something like this. I am not sure about the constract, but it should be pretty close to this..

SELECT * FROM chardonnay WHERE MATCH name AGAINST('%".$find."%' WITH QUERY EXPANSION)

give it try and let us know...

I am looking at the form processor part of your script, I believe it could use some minor rewriting too..

veedeoo 474 Junior Poster Featured Poster

If you are new to OOP, there is a framework called kohana. OOP is pretty dry in this framework, you will not get wet that for sure, and most importantly NO NOSE BLEEDS that never stops like the one I have :). You can probably use this framework in about an hour or two after learning its basic construct , as long as you can write a simple function($foo){ return $bar; }, should be enough for you to start experimenting with Kohana "framework". As your knowledge in OOP progresses, you can then attemp to use the ORM, Sprig, and Jelly Object modeling.

Again, a problem for good documentation is always hard to find. The developers always assumed we always know something.

For beginners in framewoking, Kohana is a good training ground, because you don't really need to write many codes to make it work. One unique characteristic of Kohana, is that you can create a database query for a particular table and at the same time, name the model file after that table. For example if we are to send a SELECT query for the table 'phonebook', the model file can be called phonebook.php, and amazingly the model class can also be named phonebook.

Filename: model/phonebook.php

<?php defined('SYSPATH') OR die('No direct access allowed.');

class Model_phonebook extends ORM {

 function get_number(){
      $result = DB::query(Database::SELECT, 'SELECT name,number FROM phonebook ORDER By id DESC LIMIT 0, 15')->execute();

      return $result;

      }
}

Interestingly enough, the controller is bind capable..again if we are to …

veedeoo 474 Junior Poster Featured Poster

Hi,

Although this codes below works, it contradict its own conditions.. Assuming that suppressant will work on mysql_connect and select, this should not be written like this..

if(!@mysql_connect($mysql_host, $mysql_user,$mysql_pass)|| !@mysql_select_db($mysql_db)){
die($conn_error);
}

Why is there a contradiction? Because you are suppressing it and yet you want it to return the error "could not Connect" on die function.

This type of coding implementation should only be use in OOP where other methods can validates if the connection exists. Otherwise, if it is in procedural..I totally agree with the notion of simplicity makes everything works with less frills.

I strongly suggests to change the above codes to something simple as this

mysql_connect($mysql_host, $mysql_user,$mysql_pass) or die(mysql_error($conn_error));
mysql_select_db($mysql_db) or die(mysql_error('Could not Connect to database table'));

The same is true with the insert query. Everyone should start where the wonderful basic coding standards reign, and then we create a more complex and extensible codes, once we are applauded by our peers in doing the basics.

if($query_run = mysql_query($query)){
$query="insert into mylibrary value('$isbn','$title')";
mysql_query($query);
echo "Successfully store in DATABASE";
}

Why is the above wrong? Because you do not need to assign the query funtion to a variable. If you want to do it with if statement, then just hit straight to the bottom of it like..

if(mysql_query($query)){
echo "It's done";
}

You codes above is totally wrong.. and here is the way of doing it in the sense of being plain as we call it as basic construct.

mysql_query("INSERT INTO example …
veedeoo 474 Junior Poster Featured Poster

Dude,

What the text meant is not to crawl any pages within and below the directory where the robot.txt is located.

If you don't want the spider to crawl the image directory, you can give the instruction like this

User-agent: *
Disallow: /images/

this

User-agent: *

is for all the robots or spiders.. I would disallow a crawl from an evil spider such as slurp, and allow the rest. so, my code will be something like this

User-agent: *

User-agent: Slurp
Disallow: /

The above will disallow the spider Slurp to crawl my site.

You must itimized all the not allowed bots.

veedeoo 474 Junior Poster Featured Poster

You should be rewarded for solving this question. :) Check your skill endorsement...I pretty seldom I stop by in this part of Daniweb. It is not that I can't do all these things, but I found the other side more challenging..

veedeoo 474 Junior Poster Featured Poster

hi,

ERRATA!

change this

foreach($posts_array as $posting) : setup_postdata( $post );

to this

foreach($posts_array as $post) : setup_postdata( $post );

Sorry for the typos.

veedeoo 474 Junior Poster Featured Poster

Hi,

Do you want to show them outside of the wordpress universe?, or are trying to create your own plugins?

Using wordpress docs as referenced here, we can easily device simple codes to retrieve and sort blog posts.

Example codes below is outside the wordpress. If you will be using it creating a plugin, the approach and coding techniques is slightly different.

include_once('wp-load.php');

global $post;

$cat = $_GET['cat'];
$how_many_post = 5; //change the number if you want more

$args = array( 'posts_per_page' => $how_many_post, 'category' => $cat);
$posts_array = get_posts( $args );

foreach($posts_array as $posting) : setup_postdata( $post );
{
  echo '<a href="'. the_permalink() .'">'. the_title() .'</a>';
}

it should work, but I have never had the chance to test it...

veedeoo 474 Junior Poster Featured Poster

@devarmagan,

!Warning! Script below is not tested. However, I am confident that it will help you isolate the problems you are having. If I don't over parenthesized or missed some semi-colons it should work as I intended it to be.

jUst a simple suggestion, why not test checkboxes in one page, to see how the recommended codes work..

For example, per Diafol's recommendation

 ? array_sum($_POST['generation']) : 0;

should work, but if you don't check if the POST is set (the entire form), then you will probably ended up 0..

Here is tester code that I think might work. Save this on a single php page called tester.php

<?php
    echo '<h4>Form submission Results</h4>';

    if(isset($_POST['submit'])&& (!empty($_POST['generation']))){

    echo 'Test One:  Array Sum Generation:  '.array_sum($_POST['generation']).'<br/> Test Two: ';

    print_r($_POST['generation']);
    }
    echo '<br/>';
    echo 'Test Three: '.(($_SERVER['REQUEST_METHOD']== 'POST')?((!empty($_POST['generation'])?array_sum($_POST['generation']) : 0 ))  :'Checkbox is empty');

    ?>
    <form method="post" action="">

    <input type="checkbox" value="1" name="generation[]" id="mother" /> <label for="mother">Mother</label>
    <br/>
    <input type="checkbox" value="2" name="generation[]" id="grandmother" /> <label for="grandmother">Grand mother</label>
    <br/>
    <input type="checkbox" value="4" name="generation[]" id="greatgrandmother" /> <label for="greatgrandmother">Great grandmother</label>
    <br/>
    <input type="checkbox" value="8" name="generation[]" id="sisters" /> <label for="sisters">Sisters</label>
    <br/>
    <input type="checkbox" value="16" name="generation[]" id="daughters" /> <label for="daughters">Daughters</label>
    <br/>
    <input type="submit" name="submit" value="submit">
    </form>

Although I haven't tested the codes above, I highly favor the result coming out from test two and three. If you want more testing procedures, please let us know.

The purpose of the script is to approximate the sum of the value submitted as proposed by Diafol. It is highly recommended to …

veedeoo 474 Junior Poster Featured Poster

Have you tried changing 127.0.0.1:3306 to the remote computer's ip e.g 192.168.4.1:3306 ?

veedeoo 474 Junior Poster Featured Poster

Hi,

Here is another option with jquery. Credits are due to css-tricks.com.. This script has been inspired by one of their published articles. I modified it to create a blinking effect announcement, but you can always use it to change the color of specific li.

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />

<title>Random Color list </title>
<head>
<style type="text/css" media="screen">

    #target {
        color:#000;

    }
    #target.color_red {

        color:red;
        font-size:18px;
    }
</style>

   <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>

   <script type="text/javascript">
function randRange(data) {
        var newTime = data[Math.floor(data.length * Math.random())];
        return newTime;
    }

function toggleSomething() {
    var timeArray = new Array(100, 500, 250, 650, 2000, 3000, 1000, 1500);

    $("#target").toggleClass("color_red");

    clearInterval(timer);
    timer = setInterval(toggleSomething, randRange(timeArray)); 
}

var timer = setInterval(toggleSomething, 1000);
// 1000 = Initial timer when the page is first loaded
</script>


</head>

<body>

<h1>My list and target</h1>

<ul>
<li>One</li>
<li>Two</li>
<li>Three</li>
<li id="target">This is a target li</li>
<ul>

</body>

</html>

You can control the random time in micro-secs by changing values in the array

var timeArray = new Array(100, 500, 250, 650, 2000, 3000, 1000, 1500);
veedeoo 474 Junior Poster Featured Poster

Hi,

Here is a simple servlet that will function pretty much the same as what you are trying to achieved.

FileName: **TestServlet.java **

 /*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
 import java.util.Random;
/**
 * Servlet provided without any warranty whatsoever.  For educational purposes only.
 * @author veedeoo
 */
public class TestServlet extends HttpServlet {

/**
 * Processes requests for both HTTP
 * <code>GET</code> and
 * <code>POST</code> methods.
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    PrintWriter out = response.getWriter();
     String[] myStrings = {"This is the first random message", "This better work when I run it",
"Welcome to the Terror Dome", "Dallas Cowboys Rock", "The class is almost over"};

        try {
            /* TODO output your page here. You may use following sample code. */
            out.println("<!DOCTYPE html>");
            out.println("<html>");
            out.println("<head>");
            out.println("<title>Servlet TestServlet</title>");            
            out.println("</head>");
            out.println("<body>");
            out.println("<h1>Servlet TestServlet at " + request.getContextPath() + "</h1>");
            Random r = new Random( );
            out.println(myStrings[r.nextInt(myStrings.length)]);
            out.println("</body>");
            out.println("</html>");
        } finally {            
            out.close();
        }
    }

// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
/**
 * Handles the HTTP
 * <code>GET</code> method.
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if …
veedeoo 474 Junior Poster Featured Poster

this

<li>[searchBlock.val]</li>

should read

<li>[searchBlock.val.title]</li>
veedeoo 474 Junior Poster Featured Poster

template engines are twig, smarty, tinybutstrong, and raintpl..

example of usage,,, say we use my pretty old version class above to fetch somethng from the database..

public function fetch_all($mode = MYSQL_ASSOC ) {
$arr = array() ;
while ($row = $this->fetch($mode)) {
$arr[] = $row ;
}
return $arr ;
}

if we use the above method and implement it to template engine, it will be something like this.. this is an old youtube search query I wrote long time ago while I was in high school.

Let us pretend this is our search.php page

$typestring = "AND (mediatype='video') " ;
        $dbFilters= "title,description,id,groupid,group_id,category,thumb, poster,embprovider, allviews, mediatype,cat_id,cat_name";
        $keywordsearch = "AND (title LIKE '%".$keywords."%' OR description LIKE '%".$keywords."%' OR tags LIKE '%".$keywords."%')" ;
        $getItems =("SELECT ". $dbFilters ." FROM media LEFT JOIN `group` ON (`media`.`groupid` = `group`.`group_id`)LEFT JOIN `category` ON (`media`.`category` = `category`.`cat_id`) WHERE `status` ='true' ".$hide." AND (`suspended`!=1 OR `suspended` IS NULL) ".$keywordsearch." ". filter_var($filterstring, FILTER_SANITIZE_STRIPPED) ." LIMIT $offset,$rowsPerPage") ;

Smarty Template engine example:

We create an object or rather an instance of the classs.

$db = new Database();

Smarty->assign('search_results',$db->fetch_all($getItems);
Smarty->display('search.tpl');

our Smarty template page search.tpl file

<ul>
{foreach $search_results as $item}
<li>{$item.title}</li>

{/foreach}

Twig Example Normally, my implmentation of twig is little different than what was on the manual. First I would create a bootstrapfile to hold the twig object or instance..

## define the location of the twig autoloader file

require_once dirname(__FILE__).'/twig/lib/Twig/Autoloader.php';

function set_template($theme,$theme_file,$content=array(),$cache){

if($cache == true){
$cache_dir = dirname(__FILE__).'/themeslocationDirectory/'.$theme.'/theme_cache';
}
else{
$cache_dir = false; …