Codeigniter : how to change path for session - codeigniter

How I can change current path from /~shinobu22/ci into /? I have problem about session lose after redirect or change page.
So, I think it's happen from my URL /~shinobu22/ (I didn't create this name MAC OS create from my username).

Have you tried changing the application/config/config.php file for the cookie path:
$config['cookie_path'] = '/';
Another option is to allow it site-wide:
$config['cookie_domain'] = ".example.com";

Related

Codeigniter force_download() No output

Fast to explain, but I can't get it to work:
In this simple code, the function force_download simply doesn't make any output.
$this->load->helper('download');
$data = file_get_contents("upload/".$filename);
$name = $no_file;
force_download($name, $data);
Here I just get a white screen, but the file content is show (well you know, the strange codified content :) I think it is simple enough, I just want the file downloaded with no other effect, am I doing something wrong?
I think this is you should do..
$this->load->helper('download');
$path = file_get_contents(base_url()."yourpath/".$filename); // get file name
$name = "test.pdf"; // new name for your file
force_download($name, $path); // start download`
Hope this helps.
EDIT:
Make sure you have a file extension on the filename you supply for the first argument to force_download().
CodeIgniter uses this to set the MIME type, and it doesn't seem to work without.
ERROR: Name or Service not known.
Step1: Opening /etc/resolv.conf (my file was empty)
Step2: Add
nameserver 8.8.8.8
nameserver 8.8.4.4
options rotate
options timeout:3
This may help.

show Your system folder path does not appear to be set correctly.

show Your system folder path does not appear to be set correctly. Please open the following file and correct this: index.php while visiting my CI project
The file mentioned in the message (index.php) is typically located in the root folder of your Codeigniter installation.
The normal files structure for Codeigniter is this.
/root_name (often named 'www' or 'htdocs')
/application
/system
index.php <- Is the file to edit
The section of the index.php where you need to make the adjustment looks like this.
/*
* ---------------------------------------------------------------
* SYSTEM DIRECTORY NAME
* ---------------------------------------------------------------
*
* This variable must contain the name of your "system" directory.
* Set the path if it is not in the same directory as this file.
*/
$system_path = 'system';
If you use the normal installation folder structure then the correct entry is 'system'. If you have moved the 'system' folder to some other location, or renamed it, then the value of $system_path must be adjusted to match the new location or name.

Magento: Moved Multistore - new store always redirect to old domain, although new base_url

I have moved a Multistore to another webserver with the following structrue:
mystore.com --> Magento Multistore installation
flowers.website.com --> symlinks to mystore.com folder
cars.website.com --> symlinks to mystore.com folder
The new setup is completely the same (only different domains and folder names).
But if I go to the new url mynewstore.com I will always be redirect to the old domain.
Things I have already done/tried:
Changed the base_urls in core_config_data
Cleared var + 777 permission
Cleared session table
Reindex
Checked htaccess for redirects
Checked index.php
Checked templates of the different stores for redirects
The important part of my index.php:
/* Store or website code */
$mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : '';
/* Run store or run website */
$mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store';
$mageRunCode = 'mystore';
$mageRunType = 'website';
Mage::run($mageRunCode, $mageRunType);
If I'm going to change the $mageRunCode to another store ID (like "flowers"), the old (!!) flower store (redirect to old flower url) will be loaded.
I guess it is hard to solve the problem without looking at the code, but I've no other idea as to try it here. I really appreciate any hint.
I once had the same problem and it took me almost a whole day to figure out what was going wrong. I had a multistore but all the stores gave a 404 page on every URL I tried. In the end the solution was to change MAGE_RUN_TYPE from website to store.
Your index.php file as you have it is overriding the MAGE_RUN_CODE and MAGE_RUN_TYPE variables because of these lines:
$mageRunCode = 'mystore';
$mageRunType = 'website';
Since they are called after their initial definitions, they;re being reset to mystore and website.
Try removing these lines, and seeing if the variables are properly passed into the Mage::run() function.
Important Notice about CHMODing to 777.
This is a potentially dangerous thing to do as it can allow public access to your filesystem. You never want to set a 777 permission set on a production site for this reason.
Set your folders to 755 and files to 644. To do this, open a shell connection and cd to your Magento root directory. Run the following command:
chmod -R 755 *; find -type f -print0|xargs -0 chmod 644
If run correctly, all of the files in your Magento installation will be set to the correct permissions.
in the index.php header add this:
$_SERVER['MAGE_RUN_CODE'] = $_SERVER['REDIRECT_MAGE_RUN_CODE'];
$_SERVER['MAGE_RUN_TYPE'] = $_SERVER['REDIRECT_MAGE_RUN_TYPE'];

QFileDialog: how to set default filename in "Save as..." dialog

I try to create "Save as..." dialog in Mac OS X. But I don't want to use QFileDialog::getSaveFileName() function, because dialog that created by this function is NOT truly-native in Mac OS X Lion. So I decide to create dialog as QFileDialog object:
auto export_dialog( new QFileDialog( main_window ) );
export_dialog->setWindowModality( Qt::WindowModal );
export_dialog->setFileMode( QFileDialog::AnyFile );
export_dialog->setAcceptMode( QFileDialog::AcceptSave );
All works fine, except one problem. I cannot set default name for saved file, so user must type this name manually every time. I know that function QFileDialog::getSaveFileName() allows to set default filename via third argument, dir (http://qt-project.org/doc/qt-4.8/qfiledialog.html#getSaveFileName). But how to set this default name without this function?
I can set default suffix for saved file via QFileDialog::setDefaultSuffix() function, but I need to set whole default name, not only default suffix.
I've tried to use QFileDialog::setDirectory() function, but it sets only directory where to save, without name of saved file.
I use Qt 4.8.1 on Mac OS X Lion.
I have found that using selectFile("myFileName"); only works if the file actually exists. In my case, the intent is to create a new file with the option of overwriting an existing file.
The solution that worked for me (Qt 5.3.2) was as follows:
QFileDialog svDlg;
QString saveFileName = svDlg.getSaveFileName(this, caption, preferredName, filter);
In the above example, preferredName is a QString that contains "C:/pre-selected-name.txt"
Restating what was in the comments for future visitors, the following line puts "myFileName" as the default name in the QFileDialog:
export_dialog->selectFile("myFileName");
Discussion: http://www.qtcentre.org/threads/49434-QFileDialog-set-default-name?highlight=QFileDialog
Not-so-helpful docs: http://qt-project.org/doc/qt-4.8/qfiledialog.html#selectFile
QString dir = QDir::homePath();
QString name = "test.txt";
QFileDialog::getSaveFileName(nullptr, tr("save file"), dir + "/" + name, tr("TXT (*.txt)"));
If you set "dir" argument, and dir is "file"(exist or not), in windows you will have default name.
With the current QT-version (5.x) you can set your preferred file-name with the argument directory in the QFileDialog.getSaveFileName() function call:
QFileDialog.getSaveFileName( directory = 'preferredFileName.txt' )
docs: http://doc.qt.io/qt-5/qfiledialog.html#getSaveFileName

Edit file.php from controller using CodeIgniter

I need to add some content to a file from a controller in CodeIgniter, in my local enviroment I do this and works fine:
$handle = fopen(APPPATH."config/file.php", "a+");
fwrite($handle, $stuff);
fclose($handle);
However the file doesn't seem to get altered when it runs in the production environment server.
At first I though it could be permission issues but chmoding 777 the directory doesn't seem to work either
It seems to me APPPATH is pointing to a different path. Make sure APPPATH is correct.
Dumb of me, I chmoded the folder containing the file but not the file itself.

Resources