cereal 1,524 Nearly a Senior Poster Featured Poster

The first argument of the anchor() function can accept an array or a string, so:

$segments = array(
    'product',
    'id',
    '1',
    '?version=12&name=mydoc'
);

# with array
echo anchor($segments, 'click me');

# with string
echo anchor('/product/id/1?version=12&name=mydoc', 'click me');

the difference between the two is that the former will output a trailing slash after the $id (with value 1) segment:

# version 1
http://localhost/product/id/1/?version=12&name=mydoc

While the latter no:

# version 2
http://daniweb.ci/product/id/1?version=12&name=mydoc

but, in both cases it should work fine, the point is to include the ? in the segment.

If you want to generate only the second version of the links through an array, then this could be done by extending the url helper, for example by simply exploding the string at the ? character and removing the right slash. In application/helpers create the file MY_url_helper.php and paste this:

<?php

if ( ! function_exists('my_anchor'))
{
    function my_anchor($uri = '', $title = '', $attributes = '')
    {
        $title = (string) $title;

        if ( ! is_array($uri))
        {
            $site_url = ( ! preg_match('!^\w+://! i', $uri)) ? site_url($uri) : $uri;
        }
        else
        {
            $site_url = site_url($uri);
        }

        if ($title == '')
        {
            $title = $site_url;
        }

        if ($attributes != '')
        {
            $attributes = _parse_attributes($attributes);
        }

        # new edit
        $querystring = explode('?', $site_url);
        $querystring[0] = rtrim($querystring[0], '/');
        $site_url = implode('?', $querystring);
        # stop edit

        return '<a href="'.$site_url.'"'.$attributes.'>'.$title.'</a>';
    }
}

Then from the view call the new function my_anchor() as submit the same arguments of the anchor() helper:

$segments …
iamthwee commented: comprehensive answer +0
cereal 1,524 Nearly a Senior Poster Featured Poster

I'm not sure I've understood but you can use both at the same time. For example you have a method like this one:

public function activation($id)
{
    $data = array(
        'id'   => $id,
        'code' => $this->input->get('code', true)
    );

    $this->load->view('signup/activation', $data);
}

And call the url in this format:

http://localhost/signup/activation/1?code=random_string_123

The important is to set to TRUE the allow_get_query in the config file, so that the appended query string will be regularly processed:

$config['allow_get_array'] = TRUE;
iamthwee commented: spot on +14
cereal 1,524 Nearly a Senior Poster Featured Poster

@gabrielcastillo good suggestion, it could be done when the script receives the POST request, decode the input, filter and send back clean data, at that point there's no need to perform it in the textarea. For example:

<?php

    if($_POST)
    {
        $filter['contents'] = htmlspecialchars_decode($_POST['contents']);

        # clean the input
        require './library/HTMLPurifier.includes.php';
        require './library/HTMLPurifier.autoload.php';
        $config = HTMLPurifier_Config::createDefault();
        $config->set('Core.Encoding', 'UTF-8');
        $config->set('HTML.Allowed', 'p,a[href|target],em,strong,div[align],br');
        $config->set('Attr.AllowedFrameTargets', array('_blank'));
        $purifier = new HTMLPurifier($config);

        $data['contents'] = $purifier->purify($filter['contents']);
    }

?>

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title>TinyMCE</title>
        <script src="//tinymce.cachefly.net/4.0/tinymce.min.js"></script>
        <script type="text/javascript">
            tinymce.init({
                selector: "textarea",
                plugins: "code",
                valid_elements : "a[href|target=_blank],strong,em,div[align],br"
            });
        </script>
    </head>
    <body>

        <h2>Test</h2>
        <form method="post">
            <textarea name="contents"><?php echo array_key_exists('contents', $_POST) ? $data['contents']:''; ?></textarea>
            <input type="submit" name="submit" value="send" />
        </form>

        <?php

        if($_POST)
        {
            echo "<h3>POST:</h3><pre>";
            highlight_string($data['contents']);
            echo "</pre>";
        }

        ?>

    </body>
</html>
cereal 1,524 Nearly a Senior Poster Featured Poster

If you can use a plain-text it will be easier, because you can use the file() function to read into an array each line of the file, then just loop it through preg_match() to extract the postal codes. Now, if these are the UK postal codes there should be a rule to match only the valid combinations. Here's an example:

<?php

$source = file('source_uk.txt');

$result = array();
$i = 0;
$pattern = "/\b([A-PR-UWYZa-pr-uwyz]([0-9]{1,2}|([A-HK-Ya-hk-y][0-9]|[A-HK-Ya-hk-y][0-9]([0-9]|[ABEHMNPRV-Yabehmnprv-y]))|[0-9][A-HJKS-UWa-hjks-uw])\ {0,1}[0-9][ABD-HJLNP-UW-Zabd-hjlnp-uw-z]{2}|([Gg][Ii][Rr]\ 0[Aa][Aa])|([Ss][Aa][Nn]\ {0,1}[Tt][Aa]1)|([Bb][Ff][Pp][Oo]\ {0,1}([Cc]\/[Oo]\ )?[0-9]{1,4})|(([Aa][Ss][Cc][Nn]|[Bb][Bb][Nn][Dd]|[BFSbfs][Ii][Qq][Qq]|[Pp][Cc][Rr][Nn]|[Ss][Tt][Hh][Ll]|[Tt][Dd][Cc][Uu]|[Tt][Kk][Cc][Aa])\ {0,1}1[Zz][Zz]))\b/";

foreach($source as $line)
{
    $result[$i]['address'] = trim($line);
    if(preg_match($pattern, $line, $match) == 1)
    {
        $result[$i]['postcode'] = trim($match[0]);
    }

    $i++;
}

print_r($result);

It will output:

Array
(
    [0] => Array
        (
            [address] => Velta - The Underfloor Heating Company, Wombwell School, S73 8AX
            [postcode] => S73 8AX
        )

    [1] => Array
        (
            [address] => Speedy Asset Services Limited, C/O Arnold Clark, CW9 5GG
            [postcode] => CW9 5GG
        )

    [2] => Array
        (
            [address] => Owen Brown Limited, Metal & Wood Shop, DE74 2NL
            [postcode] => DE74 2NL
        )

    [3] => Array
        (
            [address] => Getrag Ford Transmission, Britain, Off Speke Boulevard, L24 9LE
            [postcode] => L24 9LE
        )

    [4] => Array
        (
            [address] => PDM Ltd, Stoke Lane, NG14 5HJ
            [postcode] => NG14 5HJ
        )

    [5] => Array
        (
            [address] => Robert Kirkland (Blyth) Ltd, Belsay Close, NE61 6XG
            [postcode] => NE61 6XG
        )

    [6] => Array
        (
            [address] => MCS Ltd, C/O Carillion Advanced Works Project, BS10 5NB
            [postcode] => BS10 5NB
        )

    [7] => Array
        (
            [address] => MCS Ltd, …
cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, by "word document" are you referring to Microsoft Word file? doc or docx? Or it is just a plain-text file?

cereal 1,524 Nearly a Senior Poster Featured Poster

Hmm, I'm not sure about this. By testing I see what you mean, but I also see that if I resubmit the same form, the allowed tags will be converted again:

<!DOCTYPE html>
<html>
    <head>
        <title>TinyMCE</title>
        <script src="//tinymce.cachefly.net/4.0/tinymce.min.js"></script>
        <script type="text/javascript">
            tinymce.init({
                selector: "textarea",
                valid_elements : "a[href|target=_blank],strong,em,div[align],br"
            });
        </script>
    </head>
    <body>

        <h2>Test</h2>
        <form method="post">
            <textarea name="contents"><?php echo array_key_exists('contents', $_POST) ? $_POST['contents']:''; ?></textarea>
            <input type="submit" name="submit" value="send" />
        </form>

        <?php

        if($_POST)
        {
            echo "<h3>POST:</h3><pre>";
            highlight_string($_POST['contents']);
            echo "</pre>";
        }

        ?>

    </body>
</html>

So the first time outputs:

<p>Hello &lt;strong&gt;World&lt;/strong&gt;</p>

The second time:

<p>Hello <strong>World</strong></p>

As expected. If instead you load the code plugin:

tinymce.init({
            selector: "textarea",
            plugins: "code",
            valid_elements : "a[href|target=_blank],strong,em,div[align],br"
        });

You can submit the code throught the Tools > Code tab and it won't be converted to entities. BUT if for example you submit quote or another not whitelisted tag, it will be removed only after the resubmit, not during the first instance.

For now I stop here, hope it helps a bit to understand the problem. I think the best would be to find a method to disable completely this feature of TinyMCE and use HTMLPurifier or another similar library to clean the input.

cereal 1,524 Nearly a Senior Poster Featured Poster
cereal 1,524 Nearly a Senior Poster Featured Poster

Always inside the loopCount statement if($loopCount == 1) add this:

if(preg_match("/[A-Z]{2}(?=[\s]{1,}[0-9]{5})/", $myValue, $match) == 1)
{
    $array_two[$arrayIndex]['state'] = $match[0];
}
else
{
    $array_two[$arrayIndex]['state'] = '';
}

The pattern will search for two uppercase characters right before five digits, so NY 40214 is valid, while NY a40214 is not valid.

cereal 1,524 Nearly a Senior Poster Featured Poster

Yes, it can be done. Inside the loop that generates this array place this code:

if($loopCount == 1)
{
    if(preg_match("/[0-9]{5}/", $myValue, $match) == 1)
    {
        $array_two[$arrayIndex]['zip'] = $match[0];
    }
    else
    {
        $array_two[$arrayIndex]['zip'] = 0;
    }   
}

Full example:

foreach ($result as $myValue)
{
    $loopCount = ($loopCount<5) ? $loopCount : 0;

    switch ($loopCount)
    {
        case '0':
            $second_index="cName";
            break;

        case '1':
            $second_index="local";
            break;

        case '2':
            $second_index="days_times";
            break;

        case '3':
            $second_index="contact";
            break;

        case '4':
            $second_index="marker";
            break;
    }

    $array_two[$arrayIndex][$second_index]=$myValue;

    if($loopCount == 1)
    {
        if(preg_match("/[0-9]{5}/", $myValue, $match) == 1)
        {
            $array_two[$arrayIndex]['zip'] = $match[0];
        }
        else
        {
            $array_two[$arrayIndex]['zip'] = 0;
        }

    }

    $arrayIndex = ($loopCount>=4) ? $arrayIndex+1 : $arrayIndex;
    $loopCount++;
}

It could be placed also inside case '1' but in that case it will return before the local key.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

if it does not work give us some more information: How it does not work? What result do you expect? What kind of problem you get? And possibly show your code. My example works fine for me in Google Chrome, Mozilla Firefox and Opera. Bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

Something like this should work:

<!DOCTYPE html>
<html>
    <head>
        <title>Tabless</title>
        <style type="text/css">
            *{margin:0;padding:0;}
            .table { display:table; margin:50px auto; width:960px; position:relative; }
            .tr { display:table-row; margin:10px 0; }
            .td { display:table-cell; height:30px; }
            .strong {font-weight:bold;}
        </style>
    </head>
    <body>

        <div class="table">
            <ul class="tr strong">
                <li class="td">TEXT</li>
                <li class="td">TEXT</li>
                <li class="td">TEXT</li>
            </ul>
            <ul class="tr">
                <li class="td">TEXT</li>
                <li class="td">TEXT</li>
                <li class="td">TEXT</li>
            </ul>
        </div>

    </body>
</html>

Reference: https://developer.mozilla.org/en-US/docs/Web/CSS/display

Bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

Without the quotes and replace the dot with a comma, dateadd() takes three arguments the format, the integer to add and the date, currently it is like you are passing only the first argument because the quotes will submit it as a single string. So change it like this:

CASE WHEN candidat_rendezvous_date IS NOT NULL THEN dateadd(hour, 1, candidat_rendezvous_date) END
cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, use dateadd():

dateadd(hour, 1, candidat_rendezvous_date)
cereal 1,524 Nearly a Senior Poster Featured Poster

The loops seem to be fine, the error means that $array_two is served as a string not as an array. Check if there is an intermediate step that resets the variable.

cereal 1,524 Nearly a Senior Poster Featured Poster

Remove the semicolon preceding extension otherwise the line is considered a comment and remove also the double quotes, so:

extension=php_com_dotnet.dll
cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, try to remove the white spaces between the addresses in the destination variables $to and $to2, so these:

$to      = "email@gmail.com, ".$reg_email;
$to2     = "email@gmail.com, admin@xxxxxxx.com";

Should be:

$to      = "email@gmail.com,".$reg_email;
$to2     = "email@gmail.com,admin@xxxxxxx.com";
cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, show the query generated by your script, i.e.:

print_r($qry);

Then try to run the same query through a mysql client, from shell or by PHPMyAdmin. And add:

$res = mysql_query($qry) or die(mysql_error());

To be sure it runs fine.

cereal 1,524 Nearly a Senior Poster Featured Poster

The problem is the scope of the function not the include(), a function will not consider an external variable unless this is global and you define it inside the function, for example:

<?php

include 'conn.php';

function q()
{
    global $conn;
    $stmt = $conn->query("select * from users limit 1");
    return $stmt->fetch(PDO::FETCH_ASSOC);
}

print_r(q());

As alternative you can pass the connection as argument of the function:

<?php

include 'conn.php';

function q($conn)
{
    $stmt = $conn->query("select * from users limit 1");
    return $stmt->fetch(PDO::FETCH_ASSOC);
}

print_r(q($conn));

Another alternative is to return from the included file, for example:

$conn = new PDO('config', '', '');
return $conn;

And then:

<?php

$conn = include 'conn.php';

function q($conn)
{
    $stmt = $conn->query("select * from users limit 1");
    return $stmt->fetch(PDO::FETCH_ASSOC);
}

print_r(q($conn));

Check the documentation:

cereal 1,524 Nearly a Senior Poster Featured Poster

There are many. Among the Google Fonts, I think good compromises are Roboto and Lato:

cereal 1,524 Nearly a Senior Poster Featured Poster

Yep, you have to buy the license to use it as webfont and then you apply it to the website through the @font-face attribute. In order to work you need to host the file in your server or in a CDN (Content Delivery Network).

For the license check here:

If you click on Webfont View you can read the license agreement, this is important because it explains how you can use the font. In some cases, for example, you cannot use a font to create a logo or for commercial sites.

Additional note: if you go through the above link and read the licensing tab, you will see that they allow the webfont for 250000 views and after that the font must be bought another time.

cereal 1,524 Nearly a Senior Poster Featured Poster

Or is it destined to default down to Arial a majority of the time (provided the user doesn't have Helvetica Neue or Helvetica installed on their machines)?

Correct.

But you can include a font from a remote server, check for example at Google Fonts: http://www.google.com/fonts

cereal 1,524 Nearly a Senior Poster Featured Poster

Use a foreach loop to get the keys and the values:

foreach($array as $key => $value)
{
    echo "$key has variable $value";
}

You can also use array_keys() and array_values(), for example:

$akeys = array_keys($array);
$avalues = array_values($array);

for($i = 0; $i < count($array); $i++)
{
    echo "{$akeys[$i]} has variable {$avalues[$i]}";
}

Another approach with next(), current() and key():

for($i = 0; $i < count($array); $i++)
{
    echo key($array) ." has variable ". current($array) . "<br />";
    next($array);
}

Reference: http://php.net/manual/en/ref.array.php

cereal 1,524 Nearly a Senior Poster Featured Poster

Maybe I got it, add $stmt->store_result(); before num_rows. Looking better at my previous test I was getting your same output, now is:

mysqli_stmt Object
(
    [affected_rows] => 1
    [insert_id] => 0
    [num_rows] => 1
    [param_count] => 1
    [field_count] => 1
    [errno] => 0
    [error] => 
    [sqlstate] => 00000
    [id] => 1
)
diafol commented: Fantastic! Big thanks +0
cereal 1,524 Nearly a Senior Poster Featured Poster

Hi!

It seems to work fine form me, but this:

$stmt->$mysqli->bind_param("s", $dbname);
$stmt->$mysqli->execute();

should be:

$stmt->bind_param("s", $dbname);
$stmt->execute();

My example:

$stmt = $mysqli->prepare("SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = ?");
$stmt->bind_param("s", $dbname);
$stmt->execute();

print_r($stmt);
$result = $stmt->get_result();

while($r = $result->fetch_array(MYSQLI_BOTH))
{
    echo $r[0];
}

And outputs:

mysqli_stmt Object
(
    [affected_rows] => -1
    [insert_id] => 0
    [num_rows] => 0
    [param_count] => 1
    [field_count] => 1
    [errno] => 0
    [error] => 
    [sqlstate] => 00000
    [id] => 1
)

And the dbname.

Consider that if you're using mysqli_stmt::get_result(), this is available only if you using MySQLi through the MySQL Native Driver.

cereal 1,524 Nearly a Senior Poster Featured Poster

Add the fourth parameter and it will cut the word:

wordwrap($string, "80", "<br>", true);
diafol commented: heh, rep for infinite patience +14
cereal 1,524 Nearly a Senior Poster Featured Poster

In addition check also this link: http://php.net/migration54

cereal 1,524 Nearly a Senior Poster Featured Poster

Exactly, as I wrote in my last post, check line 796:

$reg_contact_h = mysqli_real_escape_string($dbc, trim($_POST['reg_contact_h']));
$reg_contact_m = mysqli_real_escape_string($dbc, trim($_POST['reg_contact_m']));

And then line 1018:

<tr>
    <td class="mainans">Contact Details*</td>
    <td>
        <label for="rqst_contact_h"></label>
        <input type="text" name="rqst_contact_h" class="roundedfield" id="rqst_contact_h" value="<?php if (!empty($reg_contact_h)) echo htmlspecialchars($reg_contact_h, ENT_NOQUOTES, 'UTF-8'); ?>" size="20">
        <label for="rqst_contact_m"></label>
        <input type="text" name="rqst_contact_m" class="roundedfield" id="rqst_contact_m" value="<?php if (!empty($reg_contact_m)) echo htmlspecialchars($reg_contact_m, ENT_NOQUOTES, 'UTF-8'); ?>" size="20">
    </td>
</tr>

If you try to print your POST request you will get:

Array
(
    [rqst_contact_h] => 12
    [rqst_contact_m] => 17
)

Instead it should print:

Array
(
    [reg_contact_h] => 12
    [reg_contact_m] => 17
)

Otherwise the variables at lines 796 & 797 will stay empty.

The issue is given by the name attribute in the input fields because it differs from all the others, in all your script it refers as reg_contact_h, inside the form, instead is named rqst_contact_h.

cereal 1,524 Nearly a Senior Poster Featured Poster

Maybe I got it: the name in the input field is rqst_contact_h while the script searches for reg_contact_h in the POST array and the same happens with reg_contact_m. So this:

<input type="text" name="rqst_contact_h" class="roundedfield" id="rqst_contact_h" value="<?php if (!empty($reg_contact_h)) echo htmlspecialchars($reg_contact_h, ENT_NOQUOTES, 'UTF-8'); ?>" size="20">

Must be:

<input type="text" name="reg_contact_h" class="roundedfield" id="reg_contact_h" value="<?php if (!empty($reg_contact_h)) echo htmlspecialchars($reg_contact_h, ENT_NOQUOTES, 'UTF-8'); ?>" size="20">

Otherwise change the server-side part, i.e. this:

$reg_contact_h = intval(trim($_POST['reg_contact_h']));

Becomes:

$reg_contact_h = intval(trim($_POST['rqst_contact_h']));

If it does not work, try by printing all the POST array:

print_r($_POST);

So you can check if the values are correct. If still in doubt and if you can, then please share all the part of the code that receives the POST request. Hope it helps! :)

cereal 1,524 Nearly a Senior Poster Featured Poster

Ok try to do the same with the integer columns, since you're using prepared statements you can avoid mysqli_real_escape_string().

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi ignnniter, just a suggestion: strpos can lead to the same problem of the strstr approach, because it will check only for the first occurrence.

Tpojka suggested preg_match which is a better solution because you can use a pattern to return the last at-sign segment in the email i.e. the domain part. Here's an example:

<?php

$whitelist = array(
        '@some.tld',
        '@mine.tld'
    );

function checkMailDomain($mail, $whitelist)
{
    if(preg_match('/@(?!.*@).*+/', $mail, $matches) == 1)
    {
        return in_array($matches[0], $whitelist) ? true:false;
    }

    return false;
}

$mail = 'example\@some.tld@evil.org';
echo checkMailDomain($mail, $whitelist) === true ? $mail .' is allowed': $mail .' is not allowed';

$mail = 'example@mine.tld';
echo checkMailDomain($mail, $whitelist) === true ? $mail .' is allowed': $mail .' is not allowed';

It will output:

example\@some.tld@evil.org is not allowed
example@mine.tld is allowed

The above pattern /@(?!.*@).*+/ works like this: match the at-sign and all the following text that is not followed by another at-sign.

Reference: http://www.rexegg.com/regex-disambiguation.html

Bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

Regarding the integers it seems all fine. Are you allowing negative integers?

Because if the integer column in the database is unsigned the negative value will be translated to 0, test:

> create table test(id int unsigned not null);
> insert into test (id) values(-200);
Query OK, 1 row affected, 1 warning (0.11 sec)

> show warnings;
+---------+------+---------------------------------------------+
| Level   | Code | Message                                     |
+---------+------+---------------------------------------------+
| Warning | 1264 | Out of range value for column 'id' at row 1 |
+---------+------+---------------------------------------------+

> select * from test;
+----+
| id |
+----+
|  0 |
+----+
1 row in set (0.01 sec)

As you see, in such case you will get a warning, but not an error and from PHP it will seem to work as expected.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, you can do it on your own, read this:

It explains all the steps to create your own certificates and CA.

RikTelner commented: Thanks +2
cereal 1,524 Nearly a Senior Poster Featured Poster

Not even because, according to the RFC3696 an email like this one:

test\@mydomain.com@evil.org

is still a valid email address.

Tpojka commented: Helped me with better understanding of mailing services +2
cereal 1,524 Nearly a Senior Poster Featured Poster

@matrixdevuk be careful with this solution, because strstr() will check only for the first occurence of the searched pattern, so if I submit something like this:

mydomain.net@evil.org

it will pass this check.

Docs: http://php.net/strstr

cereal 1,524 Nearly a Senior Poster Featured Poster

This:

return Redirect::route('worktable1.show', $data);

Will redirect the request to another method. In your routes.php file you should have something similar to this:

Route::get('/page/{guid?}', array(
    'uses' => 'WorktableController@getPage',
    'as' => 'worktable1.show'
));

So, what you should show to us is the method that receives this datum, not the one from which you send it. Also don't change the view, $data in my example is an array to pass the variables to the view, so:

{{ Form::hidden('guid', $guid) }}

If for example you set more than one variable in the method controller:

public function getPage($guid)
{
    $data['guid'] = $guid;
    $data['msg'] = 'hello world';

    return View::make('page.form', $data);
}

Then in the view, you can do this:

{{ $guid }}

{{ $msg }}
cereal 1,524 Nearly a Senior Poster Featured Poster

Have you defined the variable in the method of the controller? For example:

public function getPage($guid)
{
    $data['guid'] = $guid;
    return View::make('page.form', $data);
}
cereal 1,524 Nearly a Senior Poster Featured Poster

It can be done also at query level by using dayofweek(). Differently from PHP the range is 1-7: 1 for sunday, 7 for saturday, for example:

 select * from images where dayofweek(created_at) NOT IN(1,7);

Docs: http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_dayofweek

cereal 1,524 Nearly a Senior Poster Featured Poster

The pg_fetch_array() function takes 3 arguments, not 2, so change it to:

while ($filesrow = pg_fetch_array($movie_file_result, NULL, PGSQL_ASSOC))

Documentation:

Bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

from the command line check if the oci8 module is loaded:

php -r 'echo extension_loaded("oci8") ? "true":"false";';

You can also list all the modules loaded by using:

php -m

The PHP version used in command line is known as CLI version and the configuration of this is usually different from the Apache version. They use different php.ini files. So if in the Apache version you see extension=oci8.dll or something similar, copy this to the php.ini of the CLI version and it should work.

Also by using oci_connect() do you get the same error? Ocilogon is an alias of oci_connect and the alias is deprecated since PHP 5.4.0.

More information about the installation process:

cereal 1,524 Nearly a Senior Poster Featured Poster

It means that you have to compare the date string with the one in the filenames and get the most recent. I suppose you cannot consider ctime/mtime/atime, correct? Because if one of the old files is changed it will prompt ahead.

I'm not good with bash scripts but here's an example that seems to work fine:

#!/bin/bash

cd $REP_DATAS/path

current=$(date -u --date='now' '+%F %H:%M')
file_is_old=3
limit=$file_is_old
result=''

dateQ='20[0-9]{2}(0[1-9]|1[0-2])([0-2][0-9]|3[0-1])_([0-9]{4})'
list='*.tar.Z'

for file in $list
    do
        if [[ $file =~ $dateQ ]]
        then

            match=$BASH_REMATCH

            year=${match:0:4}
            month=${match:4:2}
            day=${match:6:2}
            hour=${match:9:2}
            minute=${match:11:2}

            check=$(date -u --date="$year-$month-$day $hour:$minute" '+%F %H:%M')

            diff ()
            {
                printf '%s' $(($(date -u --date="$current" +%s) - $(date -u --date="$check" +%s)))
            }

            fileage=$(($(diff) / 60 / 60 / 24))

            if [ $fileage -le $limit ]
            then
                let limit=fileage
                export result="$file"
            else
                continue
            fi

            if [ $fileage -ge $file_is_old ]
            then
                result="-en \E[47;31m\033[1m Warning: $file is old \033[0m\n"
                tput sgr0
            else
                result=$file
            fi

        fi
    done

echo $result

I'm sure this can be rewritten a lot better, so before using it wait for other suggestions or, better, check the bash documentation.

Reference:

Good luck! :)

cereal 1,524 Nearly a Senior Poster Featured Poster

It should work minimum once evenif the file is two weeks old. The objective is just to display the date of file, if its not new, it will disply in red message as alert that file is very old.

This is very different from what you were asking in your previouses posts.

To get files with a date in the filename change the pattern to match the numbers, something like:

dateQ='([0-9])'

Or:

dateQ='20[0-9]{2}(0[1-9]|1[0-2])([0-2][0-9]|3[0-1])'

An updated version of the script:

#!/bin/bash
cd $REP_DATAS/path

dateQ='20[0-9]{2}(0[1-9]|1[0-2])([0-2][0-9]|3[0-1])'

list='*.tar.Z'

for file in $list
do
    if [[ $file =~ $dateQ ]]
    then
        echo $file
    fi
done

If you still have problems post your updated script and explain exactly your goals.

cereal 1,524 Nearly a Senior Poster Featured Poster

line 6: [: -eq: unary operator expected

The error means $u is missing or is null, so this fails:

if [ ${u} -eq 1 ] ; then

In my example this is defined by:

u=$(date +%u)

So it should work fine.

cereal 1,524 Nearly a Senior Poster Featured Poster

Regarding your first issue, this is probably caused by nl2br, everytime you print the code to the textarea it will translate the new lines to <br />, but it will not remove the new lines. If you remove strip_tags() from the below script, add few lines to the textarea and start to resubmit the form, you will see how the newlines will multiply.

Regarding your second issue, if those are integers then use trim() and intval() so you remove extraspaces and if the submitted datum is not an integer, it will return 0.

Here's an example:

<?php

    $reg_info = 'Hello World';
    $reg_contact_h = 12;
    $reg_contact_m = 17;

    if($_POST)
    {
        print_r($_POST);

        $reg_info = nl2br(strip_tags($_POST['reg_info']), true);
        $reg_contact_h = intval(trim($_POST['rqst_contact_h']));
        $reg_contact_m = intval(trim($_POST['rqst_contact_m']));
    }

?>
<html>
    <head>
        <title>Eban Bury Test Page</title>
    </head>
    <body>
        <form method="post" action="">
            <textarea name="reg_info" cols="45" rows="5" class="roundedfield" id="reg_info"><?php if (!empty($reg_info)) echo htmlspecialchars($reg_info, ENT_NOQUOTES, 'UTF-8'); ?></textarea>

            <label for="rqst_contact_h"></label>
            <input type="text" name="rqst_contact_h" class="roundedfield" id="rqst_contact_h" value="<?php if (!empty($reg_contact_h)) echo $reg_contact_h; ?>" size="20">

            <label for="rqst_contact_m"></label>
            <input type="text" name="rqst_contact_m" class="roundedfield" id="rqst_contact_m" value="<?php if (!empty($reg_contact_m)) echo $reg_contact_m; ?>" size="20">

            <input type="submit" name="submit" value="send" />
        </form>
    </body>
</html>

Hope it helps, bye! :)

cereal 1,524 Nearly a Senior Poster Featured Poster

Try to zip it. By the way for me it works fine.

cereal 1,524 Nearly a Senior Poster Featured Poster

You can change the approach: with $dateQ you set also the time segment %H%M, not only the day, so if you search for a file of 20140106 you find it only if you match also the hour and the minute segment, i.e.: 1655.

If you cannot avoid the time segment in filenames, then you can change $dateQ to generate only the date segment, so:

dateQ=`date --date='-3 day' +'%Y%m%d'`

instead of:

dateQ=`date --date='-3 day' +'%Y%m%d_%H%M'`

and use it as a regular expression to match the file:

#!/bin/bash
cd $REP_DATAS/path
u=$(date +%u)

if [ ${u} -eq 1 ] ; then
dateQ=`date --date='-3 day' +'%Y%m%d'`
else
dateQ=`date --date='-1 day' +'%Y%m%d'`
fi

list='*.tar.Z'
for file in $list
do
    if [[ $file =~ $dateQ ]]
    then
        zcat $file | tar xvf -
    fi
done

Where list can also be limited to the last 10 modified files, so the script does not have to loop against all files:

list='ls -t *.tar.Z | head -n 10'

You can change it as you prefer.

Note a part: you were using %H%m which will print hourmonth not hourminutes, so use %M to get the minutes.

cereal 1,524 Nearly a Senior Poster Featured Poster

Ok, so the error is file not found or something else? Currently you're not checking if the file is available, try to add a check, and change the extracting command, an example:

file=filename_$dateQ.tar.Z

if [ -f $file] ; then
zcat $file | tar xvf -
else
echo "$file not found"
fi
cereal 1,524 Nearly a Senior Poster Featured Poster

Add $ to "dateQ" otherwise you get filename_dateQ.tar.Z instead of the date & time string:

tar xvf filename_"$dateQ".tar.Z
cereal 1,524 Nearly a Senior Poster Featured Poster

Consider also the PDO library, it supports more databases: MySQLi is limited to MySQL and his forks, while PDO can query MySQL, Oracle, SQlite, PostgreSQL, MSSQL and others.

That way you can change database without worrying about rewriting all the code with the specific extensions.

mattyd commented: Thank you. +7
cereal 1,524 Nearly a Senior Poster Featured Poster

Is the dbms_output enabled? If you run show errors do you get any information?

cereal 1,524 Nearly a Senior Poster Featured Poster

You can use preg_match(), an example:

<?php

$string = "Decrypt the following random string: O2tsOGJeLj0saj07ODM1IQ==";

preg_match('/:\s(.*)/', $string, $match);

print_r($match[1]);

The pattern /:\s(.*)/ searches the string after :, but you could also use explode():

$res = explode(':', $string);
echo trim($res[1]);

Docs: