Codeigniter - make email unreadable by bots - codeigniter

Is there a method in codeigniter to make email links unreadable by bots? If not does anyone recommend a decent simple solution?

Oops..
Codeigniter has a function safe_mailto() in the URL helper

I was told this will work for google search appliance
<!--googleoff: index-->
my email
<!--googleon: index-->
Source: http://perishablepress.com/tell-google-to-not-index-certain-parts-of-your-page/
Please let me know if is incorrect.

There probably isn't any perfect solution here, especially if you don't want to inconvenience your users.
One simple method (which could be combined with the google comments mentioned by ajreal), would be to use entity encoding to obfuscate their source. This would block simple bots.
See here for some details: http://www.wbwip.com/wbw/emailencoder.html

CodeIgniter has a safe_mailto() method in the URL Helper class that obfuscates e-mail addresses in the HTML source code, without affecting the end user.
https://codeigniter.com/userguide3/helpers/url_helper.html#safe_mailto
Example Template Code:
<p>My e-mail address is <?php $this->load->helper('url'); echo safe_mailto('abc#gmail.com'); ?>.</p>
Example HTML Output:
<p>My e-mail address is <script type="text/javascript">
//<![CDATA[
var l=new Array();
l[0] = '>';
l[1] = 'a';
l[2] = '/';
l[3] = '<';
l[4] = '|109';
l[5] = '|111';
l[6] = '|99';
l[7] = '|46';
l[8] = '|108';
l[9] = '|105';
l[10] = '|97';
l[11] = '|109';
l[12] = '|103';
l[13] = '|64';
l[14] = '|99';
l[15] = '|98';
l[16] = '|97';
l[17] = '>';
l[18] = '"';
l[19] = '|109';
l[20] = '|111';
l[21] = '|99';
l[22] = '|46';
l[23] = '|108';
l[24] = '|105';
l[25] = '|97';
l[26] = '|109';
l[27] = '|103';
l[28] = '|64';
l[29] = '|99';
l[30] = '|98';
l[31] = '|97';
l[32] = ':';
l[33] = 'o';
l[34] = 't';
l[35] = 'l';
l[36] = 'i';
l[37] = 'a';
l[38] = 'm';
l[39] = '"';
l[40] = '=';
l[41] = 'f';
l[42] = 'e';
l[43] = 'r';
l[44] = 'h';
l[45] = ' ';
l[46] = 'a';
l[47] = '<';
for (var i = l.length-1; i >= 0; i=i-1) {
if (l[i].substring(0, 1) === '|') document.write("&#"+unescape(l[i].substring(1))+";");
else document.write(unescape(l[i]));
}
//]]>
</script>.</p>

Related

How to create a product in Prestashop 1.7

I create my first module in Prestashop 1.7.4. This is my code:
public function createProductsObject()
{
$product = new Product;
$product->name = $productName;
$product->ean13 = '';
$product->reference = '';
$product->id_category_default = $getCategoryID;
$product->category = $getCategoryID;
$product->indexed = 1;
$product->description = $description;
$product->condition = 'new';
$product->redirect_type = '404';
$product->visibility = 'both';
$product->id_supplier = 1;
$product->link_rewrite = $link_rewrite;
$product->quantity = $singleStock;
$product->price = $price;
$product->active = 1;
$product->psoft_hurtobergamo_id = $productID;
$product->add();
$product->addToCategories($getCategoryID);
This function in not complite. But this is not important right now. Variable productName hase this value:
Array ( [0] => Test [1] => Test) )
Beacause I have two language. The problem is. Why I dont have the name after the product is create ?
thanks for help.
To resolve this problem I add new index to my array.
$productName = array('0' => '');
$link_rewrite = array('0' => '');
and then add values to array start from index 1. Because the first language has identity value set to 1. The second, 2.
for ($i = 1; $i <= $getNumberOfAvailableLanguage; $i++)
{
array_push($productName, $name);
array_push($link_rewrite, $clean1);
}

how can i hide controller name from the url in codeigniter

i have both admin panel and also one more front panel.....i have different controller for both and in my routes.php i made changes but because of that some links are not working
$route['default_controller'] = "site";
$route['404_override'] = '';
$route['contact'] = 'site/contact';
$route['events'] = 'site/events';
$route['terms'] = 'site/terms';
$route['privacy'] = 'site/privacy';
$route['newevent'] = 'site/add_event';
$route['(:any)'] = "site/$1";
//$route['(:any)'] = "backos/$1";
$route['listevents'] = 'backos/events';
$route['listwhatsapp'] = 'backos/whatsapp';
$route['add_artist'] = 'backos/add_artist';
$route['add_club'] = 'backos/add_club';
$route['index'] = 'backos/index';
$route['check'] = 'backos/check';
$route['add_event'] = 'backos/add_event';
$route['add_city'] = 'backos/add_city';
$route['add_locality'] = 'backos/add_locality';
//$route['(:any)'] = "backos/$1";
this is my routes.php file.
try this...
$route['default_controller'] = "site";
$route['404_override'] = '';
$route['contact'] = 'site/contact';
$route['events'] = 'site/events';
$route['terms'] = 'site/terms';
$route['privacy'] = 'site/privacy';
$route['newevent'] = 'site/add_event';
$route['listevents'] = 'backos/events';
$route['listwhatsapp'] = 'backos/whatsapp';
$route['add_artist'] = 'backos/add_artist';
$route['add_club'] = 'backos/add_club';
$route['index'] = 'backos/index';
$route['check'] = 'backos/check';
$route['add_event'] = 'backos/add_event';
$route['add_city'] = 'backos/add_city';
$route['add_locality'] = 'backos/add_locality';
// this is a catch all if you don't put it as
// the last one everything else below it wont work!
$route['(:any)'] = "site/$1";

How do I fix charset problems in .gs script?

I have a problem with charsets.
I parsed a csv file in google-app-engine and I'm posting to an uiapp table.
But I checked special characters like áéíóú and those are not well displayed (?square symbol).
When I was setting up my code I played writing the string imported to a google docs document and it worked the same.
some advice please?
I search for:
a global charset definition to the code. or
string var transformation that makes the chars appear like I want to. (avoiding html &number definitions.
Is this related to the blob object?
The thing is important i come from spain and we need such characters.
app that get's a csv ';' delimited file and shows it's content
I post all my code, it's barely as the tutorial that is given.
function arreglaUrl(cadena){
var texto = cadena[cadena.length - 2]
if (texto == ''){
cadena[cadena.length - 2] = 'Sin enlace';
}
else{
cadena[cadena.length - 2] = '<center>Link.</center>' ;
};
}
function parsedCSV(){
var listaArchivos = DocsList.getFolderById('XXXXX').getFiles()
for (var i = 0; i < listaArchivos.length; i++) {
if (listaArchivos[i].getName() == 'baul.csv'){
var origen = listaArchivos[i];
};
}
var texto = origen.getContentAsString();
var arra = Utilities.parseCsv(texto,";");
return(arra);
}
function doGet() {
var datos = parsedCSV()
var baul = Charts.newDataTable()
for (i = 0; i < datos[0].length; i++){
baul.addColumn(Charts.ColumnType.STRING, datos[0][i])
}
for (i = 1; i < datos.length; i++){
arreglaUrl(datos[i]) // this only makes some html i need to post some links
baul.addRow(datos[i])
}
baul.build();
var sectorFilter = Charts.newCategoryFilter()
.setFilterColumnLabel("sector")
.build();
var tipoFilter = Charts.newCategoryFilter()
.setFilterColumnLabel("tipo")
.build();
var searchFilter = Charts.newStringFilter()
.setFilterColumnLabel("Titulo")
.build();
var searchDesc = Charts.newStringFilter()
.setFilterColumnLabel("descripcion")
.build();
var tableChart = Charts.newTableChart().setOption('allowHtml', true).setDimensions(0,0)
.build();
var dashboard = Charts.newDashboardPanel()
.setDataTable(baul)
.bind([sectorFilter, tipoFilter, searchFilter, searchDesc], [tableChart])
.build();
var uiApp = UiApp.createApplication().setTitle('Baul de Recursos');
var anchoTotal = '100%';
dashboard.add(uiApp.createVerticalPanel()
.add(uiApp.createHorizontalPanel()
.add(sectorFilter)
.add(tipoFilter)
.setSpacing(15)
)
.add(uiApp.createHorizontalPanel()
.add(searchFilter)
.add(searchDesc)
.setSpacing(15)
)
.add(uiApp.createHorizontalPanel()
.add(tableChart).setBorderWidth(1).setHorizontalAlignment(UiApp.HorizontalAlignment.CENTER).setWidth(anchoTotal)
)
);
uiApp.add(dashboard);
return uiApp;
}
I found it, we need to get the content of the file first with a Blob object.
This function is the one I use to parse some csv info into an array:
function parsedCSV(){
//searching the file. This gets only one file in var origen
var listaArchivos = DocsList.getFolderById('XXXXXXX').getFiles()
for (var i = 0; i < listaArchivos.length; i++) {
if (listaArchivos[i].getName() == 'baul.csv'){
var origen = listaArchivos[i];
};
}
// HERE IS THE GOOD DEFINITION OF CHAR:
var texto2= origen.getBlob().getDataAsString('ISO-8859-1');
// I put all the corrected text in an array
var arra = Utilities.parseCsv(texto2,";");
return(arra);
}
This is the solved thing: https://script.google.com/macros/s/AKfycbyHa-bLWBHBr3qifbvzxecqGgGUYX8mhyo-TKoyfGvy/exec
The trick:
var textVariableName = fileObjectVariableName.getBlob().getDataAsString('ISO-8859-1');

javascript getElementById appendChild error

i am having a problem with javascript and i dont know how to solve it.
i am having this code
function addtask(tab){
var tasktag = document.createElement('tr');
var task = document.getElementById(tab).getElementsByTagName('tr').length+1;
task = tab+'r'+task;
tasktag.setAttribute('id',task);
document.getElementById(tab).appendChild(tasktag);
var tasktag2 = document.createElement('td');
var task2 = document.getElementById(task).getElementsByTagName('td').length+1;
task2 = task+'c'+task2;
alert(task2);
tasktag2.setAttribute('id',task2);
tasktag2.innerHTML =''+task2+' <br><input id=\'btn1\' type=\'button\' value=\'remove\' onClick=\"removeElement(\''+num+'\',\'body\')\" />';
document.getElementById(task).appendChild(task2);
}`
i get "Couldn't convert JavaScript argument arg 0 [nsIDOMHTMLTableRowElement.appendChild]"(from firebug).
while this code works perfect
`var num;
function addlist(){
var divTag = document.createElement('table');
if(num==undefined){num = 1;}
else{numi = num.split("t")
num=parseInt(numi[1])+1;}
num = 't'+num;
divTag.setAttribute('id',num);
divTag.setAttribute('align','left');
divTag.setAttribute('style','margin:7px;');
divTag.setAttribute('border',1);
document.body.appendChild(divTag);
var divTag2 = document.createElement('tr');
var num2 = document.getElementById(num).getElementsByTagName('tr').length+1;
num2 = num+'r'+num2;
divTag2.setAttribute('id',num2);
document.getElementById(num).appendChild(divTag2);
var divTag3 = document.createElement('td');
var num3 = document.getElementById(num2).getElementsByTagName('td').length+1;
num3 = num2+'c'+num3;
divTag3.setAttribute('id',num3);
divTag3.innerHTML =''+num+' <br><input id=\'btn1\' type=\'button\' value=\'remove\' onClick=\"removeElement(\''+num+'\',\'body\')\" /><br><input id=\'btn2\' type=\'button\' value=\'task\' onClick=\"addtask(\''+num+'\')\" />';
document.getElementById(num2).appendChild(divTag3);
}
why is this happening?thank you all for your time
When working with tables, you have to use slightly different JavaScript functions:
var row = table.insertRow(table.rows.length);
row.id = ...;
Try re-working your code to use insertRow instead of appendChild, as I am lazy.

codeigniter pagination not working as expected

I tried a lot but cant seem to figure out this, any help appreciated. My articles have votes, and I have a page which is supposed to show most voted articles. Am using codeigniter btw.
The controller:
function most_voted()
{
$per_page = 3;
$cur_page = $this->uri->segment(4);
/*
if($cur_page == "") $cur_page = 1;
else $cur_page = (integer)$cur_page;
*/
$offset = ($cur_page - 1) * $per_page;
if($offset < 0) $offset = 0;
$this->load->model('article_model');
$result_rows = $this->article_model->GetMostVoted($per_page,$cur_page);
$total_rows = sizeof($result_rows) + 10;
echo "total rows is : ".$total_rows.'<br>';
echo "cur page is : $cur_page <br>";
//$this->load->library('pagination');
$config['base_url'] = base_url().'articles/most_voted/page/';
$config['uri_segment'] = 4;
$config['num_links'] = 3;
$config['first_link'] = '<<First';
$config['last_link'] = 'Last>>';
$config['prev_link'] = '< Previous';
$config['next_link'] = 'Next >';
$config['total_rows'] = $total_rows;
$config['per_page'] = $per_page;
$this->pagination->initialize($config);
$data['articles'] = $result_rows;
$data['view_file_name'] = 'articles/all_articles_view';
$this->load->view('includes/template',$data);
//echo $this->db->last_query();
}
The model :
function GetMostVoted($limit,$offset)
{
$this->db->order_by('votes','desc');
$q=$this->db->get('cgh_articles',$limit,$offset);
if($q->num_rows() > 0)
{
foreach($q->result() as $row)
{
$data[] = $row;
}
return $data;
}
}
The problem :
Issue is that though I get pagination like
< Previous 1 2 3 4 5 Next >
but clicking on 2 goes to url : page/3
clicking on 3 goes to url : page/6
clicking on 4 goes to url : page/9
and so on.
I want a click on 2 to go to page/2, 3 to page/3, and so on. Any suggestions as to whats going wrong?
If you need any more info, please let me know, thanks.
The way the pagination class works is that it returns the item at which the page should start.
For example, url : hostanme/controller/page/9 means that the page should be rendered starting with the 9th most voted article. See the example in the codeigniter documentation.
Also, you have $total_rows = sizeof($result_rows) + 10;. Why is that ?
There is an excellent tutorial for this on nettuts.

Resources