cereal 1,524 Nearly a Senior Poster Featured Poster

Hi Sahil, try by resetting the cache of your browser, it should work fine.

cereal 1,524 Nearly a Senior Poster Featured Poster

Good for me, not it works fine. Many thanks! :)

cereal 1,524 Nearly a Senior Poster Featured Poster

Hello,
when I try to enter to the PHP forum (but also in the others under Web Development section) I get redirected to a malformed url:

http://www.daniweb.com-development/php/17

I tried also with curl:

curl --head http://www.daniweb.com/web-development/php/17
HTTP/1.1 301 Moved Permanently
Date: Tue, 18 Dec 2012 15:31:11 GMT
Server: Apache/2.2
Location: http://www.daniweb.com-development/php/17
Vary: Accept-Encoding
Content-Type: text/html; charset=iso-8859-1

same response, bye!

p.s. the same is happening also under Hardware & Software.

cereal 1,524 Nearly a Senior Poster Featured Poster

Ok but can you paste an example of this path? Because maybe your calling tmp/name.hsh which is relative to the running script, instead of /tmp/name.hsh that point to the root of the OS.

cereal 1,524 Nearly a Senior Poster Featured Poster

Change line 14 in your controller, from this:

$data['result'] = $this->user_admin_model->saveItInsInfoByUser($user_id);

to this:

$data['result'] = $this->user_admin_model->selectItinfoByUserId($user_id);

bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

It seems $FileHash variable is false or not valid. Echo that and check if the path is correct.

cereal 1,524 Nearly a Senior Poster Featured Poster

Also consider you can get some collisions with rand() and overwrite previously existing files. Add a check for existing files and, in that case, rename the new one again.

cereal 1,524 Nearly a Senior Poster Featured Poster

It seems you are redirecting to a blocked directory, are you using .htaccess file to limit access?

cereal 1,524 Nearly a Senior Poster Featured Poster

I cannot help you much on this but try COM Library: http://php.net/manual/en/book.com.php
Use this article as reference: http://devzone.zend.com/238/com_dotnet/

cereal 1,524 Nearly a Senior Poster Featured Poster

The model is fine. In your /application/config/config.php set:

$config['log_threshold'] = 4;

then reload the page and check the generated log inside /application/logs/ that should help you to find the problem, note that logs directory needs write permissions.

cereal 1,524 Nearly a Senior Poster Featured Poster

What do you get from the error log? Can you post the site_model code?

cereal 1,524 Nearly a Senior Poster Featured Poster

It depends on the options you choose: you can use the entire disk, just free space or a specific partition; in any case it's best to backup data before performing an installation.

cereal 1,524 Nearly a Senior Poster Featured Poster

I'm not sure to understand what you need but you could add a primary key with both fields:

alter table staff_info add primary key('fieldA','fieldB');

just make sure these are less than 1000 bytes and not nullable; if the same value combination is submitted the query will fail for duplicate entry. Or take a look to unique kyes. In any case paste the table structure here, it will help, bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

As diafol pointed, you are not doing the login in your curl request. Anyway I use this function, that make use of file_get_contents() and works pretty well:

<?php

function getlink($url)
{
    $version = '2.0.1';
    $format = 'xml';
    $login = 'username';
    $appkey = 'API_KEY';
    $bitly = 'http://api.bit.ly/shorten?version='.$version.'&longUrl='.urlencode($url).'&login='.$login.'&apiKey='.$appkey.'&format='.$format;

    $response = file_get_contents($bitly, TRUE);

    if($response !== FALSE)
    {
        $xml = simplexml_load_string($response);
        $link = 'http://bit.ly/'.$xml->results->nodeKeyVal->hash;
        return $link;
    } else {
        return FALSE;
    }
}

echo getlink('http://www.website.tld');

?>

which is based on http://davidwalsh.name/bitly-php
bye!

diafol commented: nice +14
cereal 1,524 Nearly a Senior Poster Featured Poster
cereal 1,524 Nearly a Senior Poster Featured Poster

You can use the function gethostbyname(): http://www.php.net/manual/en/function.gethostbyname.php

bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

Try to remove the underscore from the CSRF cookie name:

$config['csrf_cookie_name'] = 'csrfcookie';

From what I've read in the past, it seems that latests IE versions don't like it.

cereal 1,524 Nearly a Senior Poster Featured Poster

In addition to diafol suggestion, I think this can also be done at SQL level, but the_date should be converted to a datetime field in order to do comparisons, now I think it's a varchar. You need to use BETWEEN ... AND ... expression:

http://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html#operator_between

For example:

create table booking (
    id int(9) not null auto_increment primary key,
    the_date datetime null,
    id_state int(9) not null
) engine=myisam default charset=utf8;

insert into booking (the_date,id_state) values('2012-11-08 09:30:00','4'), ('2012-11-08 10:00:00','5'), ('2012-11-10 12:30:00','4'), ('2012-11-09 10:00:00','5'), ('2012-11-12 11:30:00','4'), ('2012-11-14 11:15:00','5');

select * from booking where the_date not between '2012-11-08' and '2012-11-10' and the_date <= curdate();

+----+---------------------+----------+
| id | the_date            | id_state |
+----+---------------------+----------+
|  3 | 2012-11-10 12:30:00 |        4 |
|  5 | 2012-11-12 11:30:00 |        4 |
|  6 | 2012-11-14 11:15:00 |        5 |
+----+---------------------+----------+

The output will include the end date, so just extend the range at script of SQL level. Bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

We need more details: which applications and versions? what have you tried to do? is this a fresh install or it stopped working? do you get any errors when you try to perform the install action?

From terminal try:

sudo apt-get update
sudo apt-get upgrade

and then retry to install.

cereal 1,524 Nearly a Senior Poster Featured Poster

In addition you can use alternate stylesheets, which are available also from the browser tools:

<link href="/styles/default.css" rel="stylesheet" title="default style" />
<link href="/styles/dark.css" rel="alternate stylesheet" title="dark style" />
<link href="/styles/white.css" rel="alternate stylesheet" title="white style" />

http://www.w3.org/Style/Examples/007/alternatives.en.html

To update you can set a cookie to save the CSS to load when visiting the website, for example:

<?php

$style = false;
$array_styles = array('default','dark','white');
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
    if(isset($_POST['theme']))
    {
        $time = time()+(60*60*24*7); # a week from now
        $value = in_array($_POST['theme'],$array_styles) ? $value : 'default';

        setcookie("Theme", $value, $time, "/", "mywebsite.tld", false);
        $style = $value;
    }
}

if(isset($_COOKIE['Theme']))
{
    $style = in_array($_COOKIE['Theme'],$array_styles) ? $_COOKIE['Theme']:'default';
}

echo '
    <link rel="'.($style == 'default' || $style === false ? '':'alternate ').'stylesheet" href="/styles/default.css" />
    <link rel="'.($style == 'dark' ? '':'alternate ').'stylesheet" href="/styles/dark.css" title="dark style" />
    <link rel="'.($style == 'white' ? '':'alternate ').'stylesheet" href="/styles/white.css" title="white style" />
';
?>

I didn't tested the code but it should work. More info about setcookie(): http://php.net/manual/en/function.setcookie.php

cereal 1,524 Nearly a Senior Poster Featured Poster

@Viped you can use a SSL certificate to encrypt the data between the client and the server, you will need to install a CA certificate in your server, from that moment the encrypted data will be sent through HTTPS. For internal uses you can use an auto-generated certificate, when you open the https connection the browser will warn you about the trust of the website, because the certificate is not registered, to prevent this you have to register to a Certificate Authority (CA): http://en.wikipedia.org/wiki/Certificate_authority

Check this link for more info: http://httpd.apache.org/docs/2.2/ssl/ssl_faq.html

@LastMitch wifi WEP & WPA2/TKIP keys can be cracked in minutes if the strings are weak, and once you have that it's not difficult to sniff all data passing in the wan. A part from that even a sniffer into a wired lan can catch data if the eth card is in promiscous mode. Bye :)

cereal 1,524 Nearly a Senior Poster Featured Poster

@username456453 the suggestion of blud is correct, on a server platform you can check the incoming connections through netstat command, it's quite different from the desktop platform that you are using in your assertion, and even if opening a page (into a server/desktop environment) loads multiple requests, this will be detected by the netstat command.

cereal 1,524 Nearly a Senior Poster Featured Poster

You have to add the ServerName directive into the lh-test_site file:

ServerName testsite
DocumentRoot /var/www/test_site
<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>
<Directory /var/www/test_site/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    allow from all
</Directory>

then inside /etc/hosts add:

127.0.0.1 testsite

and run a2ensite as before, it should work.

cereal 1,524 Nearly a Senior Poster Featured Poster

You can use mod_perl: http://perl.apache.org/
Or CGI: http://httpd.apache.org/docs/2.2/howto/cgi.html

For the second solution edit line 771:

AddHandler cgi-script .cgi .pl

i.e. remove the comment sign # and add .pl to the handler, then you have to add Options +ExecCGI inside the block <Directory "C:/Apache Group/Apache2/htdocs"> at line 253.

But these changes can be done at .htaccess level, just check the second link.

cereal 1,524 Nearly a Senior Poster Featured Poster

It would be easier knowing how the main arrays are generated. If the source is a database this can be done in a previous step. And also, as LastMitch pointed, post also your code. Anyway, this is a test example, it outputs the new arrays without the collision:

<?php

$data1 = array(
        array(
        '7'=>'chelsea everton villa liverpool',
        '8'=>'everton villa liverpool manutd',
        '9'=>'villa liverpool manutd arsenal',
        '10'=>'liverpool manutd arsenal newcastle'
        ),
        array(
        '23'=>'milan inter juventus napoli',
        '24'=>'inter juventus napoli roma',
        '25'=>'juventus napoli roma udinese',
            ),
        array(
        '53'=>'madrid barcelona altetico getafe',
        '54'=>'barcelona altetico getafe betis',
        '55'=>'altetico getafe betis valencia',
    '8'=>'everton villa liverpool manutd',
        )
        );

$data2 = array(
        array(
        '3'=>'milan inter juventus napoli',
        '4'=>'inter juventus napoli roma',
        '5'=>'juventus napoli roma lazio',
        ),
        array(
        '23'=>'PSG barcelona altetico getafe',
        '24'=>'barcelona monaco getafe betis',
        '25'=>'monaco getafe betis valencia',
        ),
        array(
        '37'=>'swansea watford villa liverpool',
        '38'=>'watford villa liverpool manutd',
        '39'=>'villa liverpool manutd arsenal',
        '40'=>'liverpool manutd arsenal newcastle'
        ),
        array(
        '37'=>'santos flamengo saopaulo riverplate',
        '38'=>'flamengo saopaulo riverplate penarol',
    '8'=>'everton villa liverpool manutd',
        )
        );



$n = 0;
$matches = array();
$new_data1 = array();
$new_data2 = array();
$n1 = count($data1);
$n2 = count($data2);

for($x = 0; $x < $n1; $x++)
{
    # loop $data1 array
    foreach($data1[$x] as $k1 => $v1)
    {

        for($y = 0; $y < $n2; $y++)
        {

            # loop $data2 array
            foreach($data2[$y] as $k2 => $v2)
            {
                # check if values from first and second are the same
                if($v1 == $v2)
                {

                    # $hash variable is used to save sha1 outputs of the two matching
                    # …
LastMitch commented: Thank You! +6
cereal 1,524 Nearly a Senior Poster Featured Poster
cereal 1,524 Nearly a Senior Poster Featured Poster

Try this:

<?php

$arr = array( 
  array( 
    '7'=>'repsol kawasaki honda ktm', 
    '8'=>'kawasaki honda ktm bmw', 
    '9'=>'honda ktm bmw ducati', 
    '10'=>'ktm bmw ducati yamaha'
  ), 
  array( 
    '23'=>'lamborghi ferarri mercedes hyundai', 
    '24'=>'ferarri mercedes hyundai toyota',
    '25'=>'mercedes hyundai toyota nissan',
    '26'=>'hyundai toyota nissan renault'
  ), 
);

$z = array();
foreach($arr as $k1 => $v1)
{
    $i = 0;

    foreach($v1 as $k2 => $v2)
    {
        if($i == 0)
        {
            $z[$k1][$k2] = $v2;
        }
        else
        {
            $r = explode(' ',$v2);
            $z[$k1][$k2] = end($r); # use end() to get last element in array
        }
        $i++;
    }

}

print_r($z);
?>

It will output as requested:

Array
(
    [0] => Array
        (
            [7] => repsol kawasaki honda ktm
            [8] => bmw
            [9] => ducati
            [10] => yamaha
        )

    [1] => Array
        (
            [23] => lamborghi ferarri mercedes hyundai
            [24] => toyota
            [25] => nissan
            [26] => renault
        )

)

http://www.php.net/manual/en/function.end.php
bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

My favourite is datteri with roasted almonds.
I'm not sure about the English term for datteri which is the fruit of the Phoenix plant

and dry cereal

o_o'

cereal 1,524 Nearly a Senior Poster Featured Poster

lol!

I didn't know there was an irc server here, I've registered my nick but John the chan is still in use?

cereal 1,524 Nearly a Senior Poster Featured Poster

You can perform a redirect to a "success.php" page or turn to an error page. You can do this with header():

$to      = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
    'Reply-To: webmaster@example.com' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

if(mail($to, $subject, $message, $headers)) # TRUE
{
    header('Location: success.php');
}
else                                        # FALSE
{
    header('Location: error.php');
}

http://php.net/manual/en/function.header.php

For better help post your code. Bye.

cereal 1,524 Nearly a Senior Poster Featured Poster

I think $pos_op should go before the statement, because it still doesn't exists and so this will give a boolean FALSE value when you try to send it to mysqli, so try to change the order:

$pos = $_GET['pos'];
$pos_op = $pos + 1;

$adjust             = "UPDATE modul_galleri SET pos = pos - 1 WHERE pos = ?";
$ADJUST_PREP        = mysqli_stmt_prepare($connection, $adjust);
$ADJUST_STMT_PREP   = mysqli_stmt_bind_param($ADJUST_PREP, "i", $pos_op);

bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

On your Form your <input type> should be text not passowrd.

Just a small correction: type can also be password ( http://www.w3.org/TR/html5/the-input-element.html#attr-input-type & http://www.w3.org/TR/html401/interact/forms.html#input-control-types ), the only difference between text and password is the masquerading in the client side, while on the server side you get the same string. Bye.

LastMitch commented: Didn't know that! Nice to know! +5
cereal 1,524 Nearly a Senior Poster Featured Poster

Check the manual: http://www.php.net/manual/en/reference.pcre.pattern.syntax.php

~ is a delimiter, from the manual:

Often used delimiters are forward slashes (/), hash signs (#) and tildes (~)

(.*?) it's a loop to match the contents of href attribute, bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

Use pathinfo(): http://php.net/manual/en/function.pathinfo.php

$file = 'test.jpg';
echo pathinfo($file,PATHINFO_FILENAME);
cereal 1,524 Nearly a Senior Poster Featured Poster
cereal 1,524 Nearly a Senior Poster Featured Poster

Congrats! :)

cereal 1,524 Nearly a Senior Poster Featured Poster

If the date_aquired field is already datetime you can also use strtotime():

$date = mysql_real_escape_string($_POST['datepickerID']);
$datepickerID = date('Y-m-d H:i:s', strtotime($date));

bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

No, I'm trying to understand what kind of configuration is used. The 403 error happens when the clients tries to access to a restricted directory. So try to apply these suggestions: http://www.cyberciti.biz/faq/apache-403-forbidden-error-and-solution/

Or post here more information about the broken links and the configuration files.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, are you using an .htaccess file? If yes, can you post the contents here?

cereal 1,524 Nearly a Senior Poster Featured Poster

You can boot on recovery mode, you will get a root shell, from which you can use passwd command to assign a new password to the root account. You will not need the old one, from there you can change the other accounts passwords and regain access.

cereal 1,524 Nearly a Senior Poster Featured Poster

Search the forum, this argument has been discussed many times. For example: http://www.daniweb.com/search/query/php-mass-mail/0?q=site%3A%2A%2F+php+mass+mail

cereal 1,524 Nearly a Senior Poster Featured Poster

LastMitch I think it's CodeIgniter framework :)

@nico
Change lines 20 and 21 with:

 $username = $this->input->post('username');
 $password = this->input->post('password');

so each field will be sanitized and if it is empty or wrong will return FALSE: http://codeigniter.com/user_guide/libraries/input.html

bye!

LastMitch commented: I knew that but I wasn't sure! ;) +5
cereal 1,524 Nearly a Senior Poster Featured Poster

Be aware that there is more then a php.ini file, one for cli, one for apache2. If you have the conf.d directory place the loader there, because this is a directory shared between the two versions. I don't have other ideas, sorry.

cereal 1,524 Nearly a Senior Poster Featured Poster

Add:

extension=mysql.so

to php.ini or check if there is a mysql.ini file in /etc/php5/apache2/conf.d and place this directive there, then reload the server:

sudo service apache2 reload

bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

This is in server side, it depends on php.ini directive upload_tmp_dir or if this is not set, on system configuration. Usually on linux servers this is /tmp: http://www.php.net/manual/en/ini.core.php#ini.upload-tmp-dir

cereal 1,524 Nearly a Senior Poster Featured Poster

You can use a single query to do this and get directly the rows of the second query:

$sql = mysql_query("select * from servers, (select id as ids from servers where active = '1') as s where id = s.ids");

Then use the while loop as in my previous example to print/collect the result set:

while($row = mysql_fetch_array())
{
    echo $row['id'];
    # . . .
}
mmcdonald commented: true :D +0
cereal 1,524 Nearly a Senior Poster Featured Poster

Try this:

$list = array();
while($ids = mysql_fetch_array($sql)){
    $list[] = $ids['id'];
}

print_r($list);

bye!

mmcdonald commented: good shout +1
cereal 1,524 Nearly a Senior Poster Featured Poster

Yes you can do that, I only suggest you to use arrays:

$data['home']['description'] = 'home descr..';
$data['home']['keywords'] = 'home,descr,..';
$data['home']['title'] = 'Home Title';

$data['gallery']['description'] = 'home descr..';
$data['gallery']['keywords'] = 'home,descr,..';
$data['gallery']['title'] = 'Home Title';

so, for example, if you have parameters in your URL you can use it to get the correct data:

http://www.mysite.tld/index.php?section=gallery

check if section is in $data and display:

include $path;
...
$section = $_GET['section'];
if(in_array($section,$data))
{
    echo $data[$section]['title'];
}
else
{
    echo $data['home']['title'];
}

bye!

diafol commented: genius is wasted! :( +14
cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

I think you can use Gearman, it allowes you to do parallel processing, you have to set a client to retrieve data and send it to a job server, this will call the workers registered for that particular task.

Here's a example in slow motion of the client script:

<?php

$a = range('a','z');

$gmclient = new GearmanClient();
$gmclient->addServer('127.0.0.1');

do
{
    $i = 1;
    foreach($a as $letter)
    {
        # serialize $letter if this is an array
        $gmclient->addTaskHighBackground("echo", $letter);
        $gmclient->runTasks();

        if(2%$i) sleep(2);
        $i++;
    }

    # kills this script after the loops ends if file exists
    if(file_exists(stop.txt))
    {
        break;
    }
}
while(true);

?>

and this is the worker:

<?php

$worker = new GearmanWorker();
$worker->addServer('127.0.0.1');
$worker->addFunction("echo", "task");

while ($worker->work())
{
    if ($worker->returnCode() != GEARMAN_SUCCESS)
    {
        echo "return_code: " . $worker->returnCode() . "\n";
        break;
    }
}

function task($job)
{
    $data = $job->workload(); # unserialize if you are receiving an array
    echo $data .' '. date('Y-m-d G:i:s')."\n";
}

?>

to start, open few terminals, in the first start the client and in the others the workers:

php client.php
php worker.php
...

You will see in the workers terminals the output of the above example: a simple output of letters and timings. A worker can call other workers to permform a secondary tasks, and these can be executed in background with different priorities. Check PHP manual to get install instructions:

http://php.net/manual/en/book.gearman.php

To start the gearman job server you can use this command:

gearmand -j 5 -v -l usage.log
mmcdonald commented: awesome, ill try this now thanks! +1
cereal 1,524 Nearly a Senior Poster Featured Poster

Have you tried object tag?

<object width="850px" height="550px" type="application/pdf" data="/pdf/pdf_to_display.pdf"></object>

you can place it inside the iframe page or directly in the webpage as alternative to the iframe solution. Bye.