cereal 1,524 Nearly a Senior Poster Featured Poster

@ganeshvasanth please open your own thread and share what you have done, so we can understand where is the problem.

cereal 1,524 Nearly a Senior Poster Featured Poster

It's deprecated:

So it's better to not adopt it, unless you want to update that code on your own.

The point is this: PHP 5.6 is going to be unsupported by the end of August 2017, the CodeIgniter team will not port CI 3 to new versions of PHP.

They are planning to release a new version of the framework (CI 4) by Spring of 2017 it will be based on PHP 7, from this new version the Cart library will be removed, along with Javascript, Unit_test, and Trackback libraries. There will be major differences, so it's not sure you will be able to upgrade without changing the code.

Since the new version is still not public, I would be careful to start anything new with it, because it's still not sure how the project will develop.

Source: http://forum.codeigniter.com/thread-62615.html

cereal 1,524 Nearly a Senior Poster Featured Poster

It happens because you're using NULL values, for the series it's not a bug, it's a feature:

cereal 1,524 Nearly a Senior Poster Featured Poster

Fatal error: Call to undefined function Age() in /home/jktempla/public_html/signup.php on line 55

Hi, it's the same type of error you got in your previous thread:

cereal 1,524 Nearly a Senior Poster Featured Poster

Looking at the script, it shouldn't work at all with videos as it seems to be forged to allow only images. In addition, your script file size limit is 500000, i.e. 0.5MB:

if ($_FILES["fileToUpload"]["size"] > 500000) {

while the uploaded file is 17074844, i.e. 17.07MB.

The browser can be an issue because, sometimes, it can send a wrong mime-type and if you filter through that value then the script can fail. An example is the file you sent through curl, it returned:

'type' => string 'application/octet-stream' (length=24)

which is wrong for a matroska file, the correct type should be: video/x-matroska.

Since you want to allow videos instead of getimagesize() use the Finfo library, for example:

$f = (new Finfo(FILEINFO_MIME_TYPE))->file('asd.jpg');

But in order to work fine you need a magic file, which has some definitions used to match mime types of inspected files.

I'm not sure Microsoft Windows or WAMP provides such file, for more information check the comments in the documentation or just check within your system:

Diafol's question is pertinent: if your production server will be Linux there are chances that will behave differently from your actual environment. To be sure everything will work fine, you should try to create an environment very close to the production server or, if required, code to support multiple environments.

So, try to upload the file without the IF statements, simplify: read the $_FILES array, move the file to the store location then, if it works …

cereal 1,524 Nearly a Senior Poster Featured Poster

It means that you have not included the named function in the current script, if you grouped some common functions then you have to include such collection.

Again, please refrain to use MySQL API, PHP 7 has been released and this API is not anymore supported, also you MUST use prepared statements, all your scripts I've seen here on Daniweb are highly vulnerable.

cereal 1,524 Nearly a Senior Poster Featured Poster

Can you open the logo link directly from the browser address bar? For example:

http://website.tld/images/logo/logo.png

What is the value of SITE_FAVICON?

cereal 1,524 Nearly a Senior Poster Featured Poster

"Request Timeout. Server timeout waiting for the HTTP request from the client."

I'm not much confident with WAMP setups, but this seems to be error 408. I would test PHP configuration by running the internal server, so to understand if it depends on Apache, by the upload form or something else related to WAMP.

In order to test it, create a script with:

<?php

    vardump($_POST, $_FILES);

Then run:

php -S localhost:8000 c:\test.php

And finally use curl to send a request, for example:

curl --trace c:\curl_output.txt -X POST -F filename='asd.jpg' -F file=@c:\asd.jpg http://localhost:8000/

This should create an hex dump of the entire upload cycle, from here you can maybe understand why it hangs and see if through the internal server works.

You can, then, repeat the test by pointing the curl request to your upload script (and by adjusting the -F options to match your upload form), and see what happens to the script handled by WAMP.

A part this I cannot do much else, because we are exploring the issue without seeing the actual code, so if it does not help you may want to share the form and the receiver script.

cereal 1,524 Nearly a Senior Poster Featured Poster

Apache can load a module to control the upload/download bandwith, this is not a default setting, so you should check with your hosting if there are any limits. You can also try to see the headers sent and received by the uploading session.

Also Apache can set the post max size which differs from PHP settings, check for LimitRequestBody:

This can be set in the .htaccess file to override hosting default settings.

cereal 1,524 Nearly a Senior Poster Featured Poster

In the previous century (the owls could still speak sometimes :o) ) we used to keep some sort of diary where we noted every day on which part of the project we did some work.

I do the same, I set up a sort of wiki (an index, a search, CRUD forms with Textile) in which I write about everything I develop, from database table schemas to project definitions.

diafol commented: Yes! +0
cereal 1,524 Nearly a Senior Poster Featured Poster

but in WAMP it should have it worked right? [...] now both WAMP and the server leads to a blank page

I haven't tested Josh's script, I replied only to explain why you were getting the syntax error. Have you tried to change the access token? The value hardcoded in the original script is valid only for Josh, not for you.

cereal 1,524 Nearly a Senior Poster Featured Poster

do u have to change (the array thing) in all the script?

Yes, from what I've seen you have to change line 13 and then from 60 to 62.

cereal 1,524 Nearly a Senior Poster Featured Poster

I think Pritaeas was asking for the database table structure, so open a MySQL client and run:

show create table `report`;

And return the result here, then run an example query to show us how your data was stored. The best would if you setup an SQLFiddle with some data:

In which you include the create table statement, the insert statements, and possibly a query.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

if you're using an old version of PHP, lower than 5.4 then change the array syntax to:

$posts = array();

Starting from PHP 5.4 you can use the short syntax:

$posts = [];

So the array should look like:

$posts = array(
    "GROUP1" => array(
        "565167146975015"
    ),
    "GROUP2" => array(
        "1727257750831063"
    ),
    "GROUP3" => array(
        "494510417393925"
    )
);

Upgrade whenever is possible :)

cereal 1,524 Nearly a Senior Poster Featured Poster

I have to say that I haven't tested Skeleton, I will try it. And about the others: none of those, I prefer Pure: http://purecss.io/

I ended writing my own, very basic, less frustration.

cereal 1,524 Nearly a Senior Poster Featured Poster

With best way to build you mean that it should be:

  • responsive
  • usable offline
  • provided with access control levels (ACL)
  • easy to develop
  • easy to mantain
  • else?

Since it's internal you could use an agile programming approach: start with basic functions, then add what is needed when requested.

cereal 1,524 Nearly a Senior Poster Featured Poster

Try with:

sudo service mysql stop

Then the pid file should disappear.

cereal 1,524 Nearly a Senior Poster Featured Poster

Ok, then try to reset the root password as described here:

cereal 1,524 Nearly a Senior Poster Featured Poster

Good for you :)

cereal 1,524 Nearly a Senior Poster Featured Poster

By removing the error control operator @ from this line do you get an error?

if(@mysql_num_rows($data)>0)

And if affirmative, have you tried to get the error returned by the select query?

cereal 1,524 Nearly a Senior Poster Featured Poster

Excuse me, it was late at night and I suggested an index key of an old version, the line it should not be:

$cfg['Servers'][$i]['nopassword']

but:

$cfg['Servers'][$i]['AllowNoPassword']

as defined in the documentation link.

By the way, are you able to sign in through mysql command line client?

mysql -uUSERNAME -pPASSWORD

remove -p if password was not set.

cereal 1,524 Nearly a Senior Poster Featured Poster

which one needs to have phpmyadmin installed on it, the web/php server or the machine I'm developing from.

If the database is accessible from remote then you can install PHPMyAdmin wherever you want, just edit the config.inc.php file to set the IP of the database in the host index, check the documentation here:

For the AllowNoPassword check the same documentation:

In practice set $cfg['Servers'][$i]['nopassword'] to boolean TRUE and you should be able to enter without password.

Note: this kind of setup is fine only for local (your box) development.

cereal 1,524 Nearly a Senior Poster Featured Poster

Ok, I see that the data index size depends on the pagesize value, if you don't set it you get 10 results, while, if the request is wrong you get an error array like below:

Array
(
    [error] => Array
        (
            [code] => -3
            [message] => no record found
        )

)

Also you cannot rely on response headers as they always return 200 OK, so the only way to know if request was fine is to check the error index is not set, only after this you can loop the data index and build your insert queries, so you should start with array_key_exists():

$item = json_decode($result, true);

if(array_key_exists('error', $item))
{
    # log the error, show an error message or something else
}

else
{
    # execute the insert queries here
}

Docs: http://php.net/array-key-exists
Note: to loop the data index you can do something like this:

foreach($item['data'] as $row)
{
    echo $row['is_fav'];
}

So you don't have to know how many results there are in the data index. If this is not what you were searching for then, please, explain it better, bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

Could you show $result as json string? That way I can test it and be sure about my suggestion.

still the ERROR thier and the rows are empty

What happens if the curl request returns an empty result set, you will get:

  1. an error message
  2. an empty array
  3. an array like above but with empty values
  4. other?
cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, you can access the key by doing:

$item['data'][0]['is_fav']

For the first array, then repeat the same for $item['data'][1].... You should, also, use prepared statements with MySQLi or PDO, the MySQL API has been removed from the latest PHP release.

To increase performance you can also create a batch insert. See:

cereal 1,524 Nearly a Senior Poster Featured Poster

/me I can see flames of war coming o_o

I would say because it's easy to use and, at the moment, it's easy to replace developers.

diafol commented: Yep. +15
jkon commented: Winter is coming +9
cereal 1,524 Nearly a Senior Poster Featured Poster

You have to assign a value to parameter:

<?php echo anchor('admin/pages?parameter=value', 'Click Here'); ?>

Otherwise the IF condition fails, try:

var_dump($this->input->get('parameter'));
cereal 1,524 Nearly a Senior Poster Featured Poster

You can append the query string to the link and then access it through $_GET as in pure PHP or by using $this->input->get('keyword').

For example, you have controller Blog with method show($title_slug) and you want to append a query string to show the comments, your link would look like:

http://website.tld/blog/show/hello-world-title?comments=on

in controller:

class Blog extends CI_Controller
{
    public function __construct()
    {
        parent::__construct();
    }

    public function show($title)
    {
        $comments = $this->input->get('comments');

        # other code ...
    }

}
cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

What Languages/Frameworks to use?

If your goal is to create an application rather than learning a new language/framework, then use what you know best.

where to start?

You could start by doing some research about external books APIs: like public libraries or like commercial sites as Amazon, to get automatic information about books like: descriptions, images, sample chapters and selling details. Then start by designing the database and by defining the available application actions and views.

For example: if you save the books by the ISBN code, then you could show all reviews made by users for a particular book. So, in order to allow such, you would need a page that displays the book information and all connected reviews, and the information about users that reviewed that resource. From here you can start building what is needed: table for books, table for users, table for reviews. And the sections of the application in which list, insert, modify or delete such data.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,
so, I did a test by downloading the 1.4.1.0 version, setting it up and then upgrading to the latest stable version, i.e. 1.6.1.2 and it's working fine for me.

Are you accessing as super admin? Check the ps_employee table to see if your profile_id is set to 1, if between 2 and 4 then the access to the module configuration could fail.

Once in, before starting the upgrade process, the module should show a checklist which should result all green. A part this I don't think I can help you much more, you should ask to the PrestaShop support, as this module is shipped by them, and let them help you in the upgrade stage.

Regarding the redirect, this does not seem related to PrestaShop, as the config/settings.inc.php file does not set the domain. Check your .htaccess file, if any, to see if there are some rewrite rules with the old domain name.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, I've suggested you a solution some time ago:

Have you tried that library?

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

can you access MySQL from command line client? By running below you should be able to access it:

mysql -uroot

And if affirmative can you run queries in database? In some cases, due to different installation sources, some libraries are overwritten and the server fails to return data, you can connect through the client, so it seems working, but tend to fail when you run a query. In cases like this you have to restore all the changed libraries and then it should work fine.

By the way, are you sure the socket file exists in c:/tmp/mysql.sock path?

And have you tried the above example connection with MySQLi or PDO? For example:

<?php

$servername = "localhost";
$dbname     = "mysql";
$dbusername = "root";
$dbpassword = "";

try {

    $conn = new PDO("mysql:host=$servername;dbname=$dbname", $dbusername, $dbpassword);
    $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    return $conn;
}

catch(Exception $e) {

    die('Connection failed: ' . $e->getMessage());

}
cereal 1,524 Nearly a Senior Poster Featured Poster

The 1-Click Upgrade module requires write permissions:

Warning, this module requires write permission in your root directory. Your custom template will not be updated.

source: http://addons.prestashop.com/en/administration-tools-prestashop-modules/5496-1-click-upgrade-autoupgrade.html

Test the upgrade tool on a local copy, then export the local database to the online database, do a copy of original data and try to not replace the working database, just create a parallel database and then switch the connection details to test the imported data.

cereal 1,524 Nearly a Senior Poster Featured Poster

Should i put it at the login page or how?

It depends, this will send an email only to those clients that are signing in that specific period, if this is your goal then it can work otherwise it would be better to schedule the task, if the latter is the case then check if your hosting control panel allows you to set cron job scripts.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

in PHP you could move the uploaded file to a directory outsite public_html, so that is not directly accessible by a remote client, the file then can be served only through a script. If you cannot move it out, then you can use .htaccess rules to limit the access to the defined directory.

However I don't know if Joomla allows such setups. I see they suggest how to block access to some specific files:

But they do not talk about static files, so you may want to search for a well known plugin that can do that or ask their support for a core solution.

cereal 1,524 Nearly a Senior Poster Featured Poster

I'm referring at the IF/ELSEIF statements at lines 17 and 26.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

small note: in your IF statementes if('$month'==2) (and co.) you are comparing literally the word $month, not his value, against the integer. Single quotes will NOT parse the variable, so in this case you can remove them and write:

if($month == 2)

Or with double quotes:

if("$month" == 2)

Double quotes can parse a variable and expand it to the his value. Read the documentation for more info:

cereal 1,524 Nearly a Senior Poster Featured Poster

If your final goal is to upgrade from 1.4.* to 1.6 then have you considered to use their automatic upgrade tool? Here are the links:

Other than that, the passwords in PS14 are stored in the customer table, in PS16 in ps_customer into a varchar(32) column.

So I would need the passwords(not in MD5 because I also tried to copy the MD5 from the export csv of customers in the csv but it doesn`t work)

In both cases the passwords are saved as MD5 digest, so it's not possible to decrypt the passwords because this is not an encrypter, it's an hash function that will return a result that cannot be converted to the original.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hola Luis, gracias pero la próxima vez, por favor, en Inglés.

cereal 1,524 Nearly a Senior Poster Featured Poster

To see which tables are involved check their database schema:

But the question is: you have to do this programmatically or not? If no, then you can use MySQL Workbench:

Otherwise there are few possible solutions, depending on which permissions you have on database system. For example if you have admin access (or file permission) you can probably run:

SELECT * INTO OUTFILE 'output.csv' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' FROM `tablename`;

And repeat this for each table you want to output. More information here:

The same can be done by the mysqldump tool:

By defining the format options:

mysqldump -uUSER -pPASSWORD -T /tmp/ DATABASENAME TABLENAME --fields-terminated-by=',' --fields-optionally-enclosed-by='"' --no-create-info --no-create-db

Replace USER, PASSWORD, DATABASENAME and TABLENAME with your values. To output all the tables of a database simply omit TABLENAME.

This command will create two files for each table in the defined database: tablename.sql and tablename.txt. Due to the given options --no-create-info --no-create-db the .sql files will be empty, and the .txt will hold the result sets.

This command cannot be ran from remote, it requires access to the database system.

Otherwise you have to do it through PHP: query, convert and save to file, check fputcsv():

All these solutions can be run by cron, manually or by a script, it depends on your …

cereal 1,524 Nearly a Senior Poster Featured Poster

You have to invert the arguments: first the link to the resource, then the database name. Like this:

mysqli_select_db($conn, DBNAME);
cereal 1,524 Nearly a Senior Poster Featured Poster

@Florea

Hi, open your own thread with as much details as possible.

cereal 1,524 Nearly a Senior Poster Featured Poster

So I can not use prepared statements to bind column names correct?

Exactly, you cannot.

I can bind the ASC/desc?

No, the bindParam() will accept only the PDO::PARAM_* constants defined here:

When you set:

$colname = 'created_at';
$stmt = $db->prepare("SELECT * FROM `items` ORDER BY :colname")
$stmt->bindParam(':colname', $colname, PDO::PARAM_STR);

The generated query will look like:

SELECT * FROM `items` ORDER BY 'created_at'

With quotes surrounding the :colname value, so the ORDER BY clause will not work. If you try to force it with a workaround, for example by setting it as an integer (by applying PDO::PARAM_INT) then you would get:

SELECT * FROM `items` ORDER BY 0

I could use your approach and just make $query equal to different columns to sort by and nest it in a conditional correct?

Yes, you can.

cereal 1,524 Nearly a Senior Poster Featured Poster

Is there anyway to replace the order by information with prepared statement attributes?

Unfortunately this cannot be done with current drivers. You can use a whitelist approach, instead of rewriting the query you do:

if(in_array($value, array('asc', 'desc'))
    $query = "SELECT * FROM `items` ORDER BY `date` $value";

Besides: date is a reserved word, so if used it needs backticks, as in the above example.

cereal 1,524 Nearly a Senior Poster Featured Poster

Ok, but the $g4 value is sent to the query? And if you perform the original query directly into a mysql client, do you get results?

cereal 1,524 Nearly a Senior Poster Featured Poster

Line 30, $options = array(). Why did you need to declare $options as a parameter?

The constructor works like a function, so you have to declare the expected parameters, as example when you call:

$sys = new Engine(array('abc'));

In the class you need:

class Engine {

    public function __construct($data)
    {
        # work with $data
    }

I added a default value $options = array() in case Engine is defined without a parameter:

$sys = new Engine;

But it would raise warnings, as there will be some undefined indexes. It's up to you to define the behaviour of the class, so you can decide to check if the parameter exists and if it's an array and if the indexes are those expected...

I can't understand what you mean, could you shine some more light on it? Are there any changes in outcome or something?

With your current code:

return $z;

You get:

Array
(
    [IMAGES2] => image3.jpg,image2.jpg,image1.jpg

    [IMAGES] => image1.jpg,image2.jpg,image3.jpg

    [TITLE] => Job=test

)

Which apparently is correct, but each index is spaced by a carriage return. By replacing that return with:

return array_map('trim', $z);

You get:

Array
(
    [IMAGES2] => image3.jpg,image2.jpg,image1.jpg
    [IMAGES] => image1.jpg,image2.jpg,image3.jpg
    [TITLE] => Job=test
)

This reflects in the first $toReplaceTemplate array, the result will change, as with your code the unmatched expressions were looking like:

[10] =>         --for image1.jpg,image2.jpg,image3.jpg
 as IMAGE--

With my suggestion they will change to:

[10] =>         --for image1.jpg,image2.jpg,image3.jpg as IMAGE--
Aeonix commented: Thanks! +0
cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

what is the error message? Have you tried by contacting their support service? From what I've seen you have to perform a curl request and get a response in JSON format:

But from the documentation I cannot see what would happen in case of error and what to expect. I would ask them to point you to full documentation about their API and see if there's already an official or recommended PHP SDK.

Besides, if you feel unconfortable with curl, you can use guzzle, which is an easy PHP HTTP client:

diafol commented: +1 for guzzle +15
cereal 1,524 Nearly a Senior Poster Featured Poster

By changing line 50 with:

return array_map('trim', $z);

you avoid new lines in the ParseVariables() generated array and let the regular expression match the pattern.

A problem I see is an undefined index at line 60, which is:

$toReplaceTemplate[$index] = str_replace($contentFrom, $replaceDict[$indexToGo], $toReplaceTemplate[$index]);

And in particular is caused by $replaceDict[$indexToGo]. The $indexToGo matches ++VAR++ and your class is not checking the exceptions, so you could do:

"exceptions"        => array("VAR")

At line 11, then at line 58:

$indexToGo = str_replace("++", "", $output[0]);
if(in_array($indexToGo, $options['exceptions']))
    continue;

You have to add also global $options, but I would avoid such and move the options array to constructor.

You can see the diff here: http://www.mergely.com/f2MpuXAB/

Aeonix commented: *sniff* *sniff* Did I smell, knowledge? +0
cereal 1,524 Nearly a Senior Poster Featured Poster

Check also: http://regexr.com/

Aeonix commented: OOOOH YEAH!!! 10/1! +4
cereal 1,524 Nearly a Senior Poster Featured Poster

Try sudo su then enter your password, as requested, it should log you as root.

Also read this: https://help.ubuntu.com/community/RootSudo