Skip to content

Instantly share code, notes, and snippets.

View deivisonarthur's full-sized avatar

Deivison Arthur Lemos Serpa deivisonarthur

View GitHub Profile
@deivisonarthur
deivisonarthur / .htaccess
Created July 13, 2012 14:49
.htaccess do Magento
############################################
## uncomment these lines for CGI mode
## make sure to specify the correct cgi php binary file name
## it might be /cgi-bin/php-cgi
# Action php5-cgi /cgi-bin/php5-cgi
# AddHandler php5-cgi .php
############################################
## GoDaddy specific options
@deivisonarthur
deivisonarthur / gera_cod_magento.php
Created July 19, 2012 17:42
Gerando código promocional no Magento
<?php
require_once('../app/Mage.php');
Mage::app('default');
function generateUniqueId($length = null)
{
$rndId = crypt(uniqid(rand(),1));
$rndId = strip_tags(stripslashes($rndId));
$rndId = str_replace(array(".", "$"),"",$rndId);
$rndId = strrev(str_replace("/","",$rndId));
@deivisonarthur
deivisonarthur / envia-email-magento.php
Created July 19, 2012 19:43
Envio de email pelo Magento
<?php
$mail = new Zend_Mail();
//$mail -> setBodyText( $MensagemEmHtml );
$mail -> setBodyHtml( $MensagemEmHtml );
$mail -> setFrom( "[email protected]", "Atendimento seusite" ); //Quem esta enviando
$mail -> addTo( "[email protected]", "Atendimento seusite" ); //Quem irá receber
$mail -> setSubject( "Obrigado por se cadastrar em nossa Newsletter" );
$mail -> send();
@deivisonarthur
deivisonarthur / BoletoMagento01.php
Created July 21, 2012 16:50
Boleto Magento cód 01
<!-- Deivison -->
<?php
echo "<br />";
// segunda via do boleto
if ((strpos($this->getPaymentHtml(), "Boleto") !== false) && ( $_order->getStatus() == $this->__(Mage::getStoreConfig('payment/boleto_bancario/order_status')) )) {
$orderid = $_order->getId();
echo "<span style='float:right'><a style='color:#ffb81e' href='" . $this->getUrl("boleto/standard/adminView/order_id/" . $orderid) . "' class='link-cart' onclick=\"this.target='_blank'\">" . $this->__("Gerar 2a Via do Boleto") . "</a></span>";
@deivisonarthur
deivisonarthur / BoletoMagento02.php
Created July 21, 2012 17:13
Boleto Magento cód 02
{{block type='core/template' area='frontend' template='boletonoemail/boleto.phtml' order=$order}}
@deivisonarthur
deivisonarthur / BoletoMagento03.php
Created July 21, 2012 17:42
Boleto Magento cód 03
<!-- Deivison -->
<!-- Impressão do usuário -->
<?php
// Tava assi: $this->getPaymentInfoHtml() alterado para assim: $this->getPaymentInfoHtml()
//if ((strpos($this->getPaymentInfoHtml(), "Boleto") !== false) && ( $_order->getStatus() == $this->__(Mage::getStoreConfig('payment/boleto_bancario/order_status')) )) {
//Deivison Arthur - deivison.com.br
//veja mais sobre strpos em http://br.answers.yahoo.com/question/index?qid=20100221162434AAdk34n
@deivisonarthur
deivisonarthur / BoletoMagento04.php
Created July 21, 2012 17:43
Boleto Magento cód 04
<?php
$orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
$order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
if($order->getPayment()->getMethod() == "boleto_bancario"): /*caso tenha cido escolhido boleto como meio de pagamento exibe o botão abaixo*/
?>
<center>
<button class="button" title="Clique aqui para imprimir o Boleto" onclick="window.open('<?=$this->getUrl('boleto/standard/view/order_id/'.$order->getId())?>','_blank')" type="button"><span><span>Clique aqui para imprimir o Boleto</span></span></button>
</center>
@deivisonarthur
deivisonarthur / BoletoMagento05.php
Created July 21, 2012 17:44
Boleto Magento cód 05
<!-- Deivison -->
<?php
/* Original comentado
if ($e->source_model) {
// determine callback for the source model
$factoryName = (string)$e->source_model;
$method = false;
if (preg_match('/^([^:]+?)::([^:]+?)$/', $factoryName, $matches)) {
array_shift($matches);
list($factoryName, $method) = array_values($matches);
@deivisonarthur
deivisonarthur / .htaccess
Created July 21, 2012 22:56
rewrite op-01
dominio.com/ PAGINA / ACAO (funcao) / VAR. DIVERSAS (pode ser id, string, etc..) /VAR. DIVERSAS (pode ser id, string, etc..) /VAR. DIVERSAS (pode ser id, string, etc..) / e por ai vai
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
<?php
function proxy_detect ($null) {
$proxyports=array(80,8080,6588,8000,3128,3127,3124,1080,553,554);
for ($i = 0; $i <= count($proxyports); $i++) {
if(@fsockopen($_SERVER['REMOTE_ADDR'],$proxyports[$i],$errstr,$errno,0.5)){
$sockport=true;
}
}
if(
$_SERVER['HTTP_FORWARDED']