yii: using gii outside localhost

by prettyscripts on 2010-07-30 11:37:13 • Leave a comment »

phpframeworkyii

i'm currently reviewing / learning yii, another php framework. while following the guide to configure gii, i wasn't able to access gii. 403 error was displayed.

it's because by default gii only allow access via localhost. if you're like me having a separate development server, an additional configuration is required - ipFilters:

PHP:

return array(
    ......
    'modules'=>array(
        'gii'=>array(
            'class'=>'system.gii.GiiModule',
            'password'=>'your-password',
            'ipFilters'=>array(...list of IPs...), // ***
        ),
    ),
);

line 7: enter list of ip addresses that are allowed to access gii. if you're access the site via proxy, enter the ip address of proxy server.

Tags: framework, gii, php, yii

smf: recover deleted topic

by prettyscripts on 2010-07-14 12:51:12 • Leave a comment »

smfsql

important: you must have a backup of the database with deleted topic. if not, you might as well skip this post.

instruction here is based on smf v1.1.x and uses phpmyadmin. it's a free browser based mysql administration tool. but if you're a mysql expert or you're using a different database, you can still work out sql and commands.

restore backup

create a dummy database (make sure it's not the same name as the one used by your production forum!) and restore the backup database.

locate the missing topic

you need to know the topic id. if not, look for it via smf_messages table. you can look up subject and / or body columns. once found, note ID_TOPIC.

extract missing topic

assuming the topic id is 100.

from the backup database, click sql link and run the following sql's (one by one):

Code:

select * from smf_messages where ID_TOPIC = 100

Code:

select * from smf_topics where ID_TOPIC = 100

for each of the result, click export link from bottom of the result. do not click the export link on top of the page!

you're now at export page. from export box, select sql. uncheck 'save as file'. click go.

you should see various sql statements. just copy the insert statements.

now go to the production database. open sql window. paste the above insert statement.

check your forum

the topic should be back!

Tags: delete, phpmyadmin, retrieve, smf, topic

thunderbird: backup and restore emails

by prettyscripts on 2010-06-23 16:35:26 • Leave a comment »

miscthunderbird

there are tools to backup and restore emails. but i prefer to do it the old fashion way - by directly copying the files.

where are the files

to find physical location of where emails are stored, from menu > tools > accounts settings, go to Server Settings and look for Local directory at bottom of screen. this is where the files are. this directory will be referred to as the mail directory.

to go to the mail directory , copy string from Local Directory field. go to windows start button > run..., paste the copied string into the field, which brings up windows explorer and goes directly to this directory.

backup and restore

backup emails by copying files from the mail directory.

if for any reason your email files are corrupted, you can just copy all these files from backup back to the mail directory.

to backup specific set of emails, it's best to create a folder in thunderbird and move those emails to this folder. all mails in a folder is stored as single file in the mail directory.

you will find 2 files corresponding to each folder, in the format of <folder name> and <folder name>.msf.

to restore specific set of emails, locate the set of files correspond to the folder name and copy back to the mail directory.

Tags: backup, emails, restore, thunderbird

symfony and doctrine: select distinct column

by prettyscripts on 2010-06-16 16:28:27 • Leave a comment »

phpsymfonysql

to select distinct column values from a table, there are a few things to note to make sure only distinct rows are returned.

in /path/to/lib/model/doctrine/SomeTable.class.php:

PHP:

public function getDistinctValue() {
    $q Doctrine_Query()::create()
        ->select('DISTINCT column_name as some_column')
        ->from('SomeTable');
    return $q->fetchArray();
}

notes:

  • line 3: DISTINCT must be capitalized
  • line 3: 'as' must be used, without this everything will be returned
  • line 5: use fetchArray() instead of execute(), the latter doesn't work!

Tags: distinct, doctrine, select, symfony

b2evo: hide login from user profile

by prettyscripts on 2010-06-05 02:14:35 • Leave a comment »

phpb2evolution

by default, post author's name is linked to profile page. and by default, b2evolution shows user login on profile page. this raises some security concerns - you don't want the public to know what is your login and you don't want to make it easier for hackers to hack into your system.

there is no setting in the backoffice to control this. it's all done in the skin.

the file to edit is _user.disp.php. if  this file doesn't come with the skin you're using, copy this file from the skin root directory to the skin directory. just search for the word 'Login' and delete the code, and delete anything you don't want to be shown.

if you want to link author's name directly to a website instead of user page, read this.

Tags: b2evo, login, profile, user