Script para criar conta de email no cpanel

Posted by Bento | Posted in Artigos, CPANEL, E-mail, PHP, Servidor Web | Posted on 11-10-2010-05-2008

0

Script para criar conta de email no cpanel

Antes de começar acesse o cpanel para descobrir qual o tema(skin) que esta em uso. Geralmente esta informação fica no lado esquerdo.
Veja imagem abaixo;

Tema Skin cPanel

Tema Skin cPanel

Crie um arquivo com um nome qualquer, aqui no exemplo usarei cpanel_criar_email.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<?php
$cpuser = 'usuario'; // Usuário cPanel
$cppass = 'sua-senha'; // Senha de acesso ao cPanel
$cpdomain = 'coloqueseudominio.com.br'; // Seu dominio ou IP do servidor.. ex. seusite.com.br
$cpskin = 'x3';  // indique o tema(skin) que esta em uso
 
 
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Script para criar conta de email no cpanel</title>
<link rel='stylesheet' id='nextgen_gallery_related_images-css'  href='http://blog.fabianobento.com.br/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/nextgen_gallery_display/static/nextgen_gallery_related_images.css?ver=3.8' type='text/css' media='all' />
<link rel='stylesheet' id='open-sans-css'  href='//fonts.googleapis.com/css?family=Open+Sans%3A300italic%2C400italic%2C600italic%2C300%2C400%2C600&subset=latin%2Clatin-ext&ver=3.8' type='text/css' media='all' />
<link rel='stylesheet' id='dashicons-css'  href='http://blog.fabianobento.com.br/wp-includes/css/dashicons.min.css?ver=3.8' type='text/css' media='all' />
<link rel='stylesheet' id='admin-bar-css'  href='http://blog.fabianobento.com.br/wp-includes/css/admin-bar.min.css?ver=3.8' type='text/css' media='all' />
<link rel='stylesheet' id='wp_greet_box_style-css'  href='http://blog.fabianobento.com.br/wp-content/plugins/wp-greet-box/css/style.css?ver=3.8' type='text/css' media='all' />
</head>
 
<body>
<form name="frmEmail" method="post">
<table width="400" border="0">
<tr><td>Usuário:</td><td><input name="user" size="20" value="" /></td></tr>
<tr><td>Senha:</td><td><input name="pass" size="20" type="password" /></td></tr>
<tr>
  <td>Espa&ccedil;o MB</td>
  <td><select name="select" id="select">
    <option value="100">100 MB</option>
    <option value="250">250 MB</option>
    <option value="500">500 MB</option>
  </select></td>
</tr>
 
<tr><td colspan="2" align="center"><hr /><input name="submit" type="submit" value="Criar conta de email" /></td></tr>
</table>
</form>
<!-- This website uses Linkable Title Html And Php Widget v1.2.5 Wordpress plugin developed by PepLamb (PepLamb.com) -->
<!-- START: Syntax Highlighter ComPress -->
<script type="text/javascript">
    SyntaxHighlighter.autoloader(
        'applescript			http://blog.fabianobento.com.br/wp-content/plugins/syntax-highlighter-compress/scripts/shBrushAppleScript.js',
        'actionscript3 as3		http://blog.fabianobento.com.br/wp-content/plugins/syntax-highlighter-compress/scripts/shBrushAS3.js',
        'bash shell				http://blog.fabianobento.com.br/wp-content/plugins/syntax-highlighter-compress/scripts/shBrushBash.js',
        'coldfusion cf			http://blog.fabianobento.com.br/wp-content/plugins/syntax-highlighter-compress/scripts/shBrushColdFusion.js',
        'cpp c					http://blog.fabianobento.com.br/wp-content/plugins/syntax-highlighter-compress/scripts/shBrushCpp.js',
        'c# c-sharp csharp		http://blog.fabianobento.com.br/wp-content/plugins/syntax-highlighter-compress/scripts/shBrushCSharp.js',
        'css					http://blog.fabianobento.com.br/wp-content/plugins/syntax-highlighter-compress/scripts/shBrushCss.js',
        'delphi pascal pas		http://blog.fabianobento.com.br/wp-content/plugins/syntax-highlighter-compress/scripts/shBrushDelphi.js',
        'diff patch			    http://blog.fabianobento.com.br/wp-content/plugins/syntax-highlighter-compress/scripts/shBrushDiff.js',
        'erl erlang				http://blog.fabianobento.com.br/wp-content/plugins/syntax-highlighter-compress/scripts/shBrushErlang.js',
        'groovy					http://blog.fabianobento.com.br/wp-content/plugins/syntax-highlighter-compress/scripts/shBrushGroovy.js',
        'java					http://blog.fabianobento.com.br/wp-content/plugins/syntax-highlighter-compress/scripts/shBrushJava.js',
        'jfx javafx				http://blog.fabianobento.com.br/wp-content/plugins/syntax-highlighter-compress/scripts/shBrushJavaFX.js',
        'js jscript javascript	http://blog.fabianobento.com.br/wp-content/plugins/syntax-highlighter-compress/scripts/shBrushJScript.js',
        'perl pl				http://blog.fabianobento.com.br/wp-content/plugins/syntax-highlighter-compress/scripts/shBrushPerl.js',
        'php					http://blog.fabianobento.com.br/wp-content/plugins/syntax-highlighter-compress/scripts/shBrushPhp.js',
        'text plain				http://blog.fabianobento.com.br/wp-content/plugins/syntax-highlighter-compress/scripts/shBrushPlain.js',
        'powershell ps          http://blog.fabianobento.com.br/wp-content/plugins/syntax-highlighter-compress/scripts/shBrushPowerShell.js',
        'py python				http://blog.fabianobento.com.br/wp-content/plugins/syntax-highlighter-compress/scripts/shBrushPython.js',
        'ruby rails ror rb		http://blog.fabianobento.com.br/wp-content/plugins/syntax-highlighter-compress/scripts/shBrushRuby.js',
        'sass scss              http://blog.fabianobento.com.br/wp-content/plugins/syntax-highlighter-compress/scripts/shBrushSass.js',
        'scala					http://blog.fabianobento.com.br/wp-content/plugins/syntax-highlighter-compress/scripts/shBrushScala.js',
        'sql					http://blog.fabianobento.com.br/wp-content/plugins/syntax-highlighter-compress/scripts/shBrushSql.js',
        'vb vbnet				http://blog.fabianobento.com.br/wp-content/plugins/syntax-highlighter-compress/scripts/shBrushVb.js',
        'xml xhtml xslt html	http://blog.fabianobento.com.br/wp-content/plugins/syntax-highlighter-compress/scripts/shBrushXml.js'
    );
                    SyntaxHighlighter.defaults['toolbar'] = false;     SyntaxHighlighter.defaults['tab-size'] = 4;
    SyntaxHighlighter.all();
</script>
<!-- END: Syntax Highlighter ComPress -->
 
	<script type='text/javascript'>
/* <![CDATA[ */
var photocrati_ajax = {"url":"http://blog.fabianobento.com.br/photocrati_ajax","wp_site_url":"http://blog.fabianobento.com.br","wp_site_static_url":"http://blog.fabianobento.com.br"};
/* ]]> */
</script>
 
<script type='text/javascript'>
/* <![CDATA[ */
var userSettings = {"url":"/","uid":"1","time":"1388671874"};var commonL10n = {"warnDelete":"You are about to permanently delete the selected items.n  'Cancel' to stop, 'OK' to delete."};/* ]]> */
</script>
<script type='text/javascript' src='http://blog.fabianobento.com.br/wp-admin/load-scripts.php?c=1&load%5B%5D=jquery-core,jquery-migrate,hoverIntent,utils,common,admin-bar&ver=3.8'></script>
<script type='text/javascript' src='http://blog.fabianobento.com.br/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/ajax/static/ajax.js?ver=3.8'></script>
<script type='text/javascript' src='http://blog.fabianobento.com.br/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/frame_communication/static/frame_event_publisher.js?ver=3.8'></script>
		<div id="wpadminbar" class="nojq nojs" role="navigation">
			<a class="screen-reader-shortcut" href="#wp-toolbar" tabindex="1">Skip to toolbar</a>
			<div class="quicklinks" id="wp-toolbar" role="navigation" aria-label="Top navigation toolbar." tabindex="0">
				<ul id="wp-admin-bar-root-default" class="ab-top-menu">
		<li id="wp-admin-bar-menu-toggle"><a class="ab-item"  href="#" title="Menu"><span class="ab-icon"></span></a>		</li>
		<li id="wp-admin-bar-wp-logo" class="menupop"><a class="ab-item"  aria-haspopup="true" href="http://blog.fabianobento.com.br/wp-admin/about.php" title="About WordPress"><span class="ab-icon"></span></a><div class="ab-sub-wrapper"><ul id="wp-admin-bar-wp-logo-default" class="ab-submenu">
		<li id="wp-admin-bar-about"><a class="ab-item"  href="http://blog.fabianobento.com.br/wp-admin/about.php">About WordPress</a>		</li></ul><ul id="wp-admin-bar-wp-logo-external" class="ab-sub-secondary ab-submenu">
		<li id="wp-admin-bar-wporg"><a class="ab-item"  href="http://wordpress.org/">WordPress.org</a>		</li>
		<li id="wp-admin-bar-documentation"><a class="ab-item"  href="http://codex.wordpress.org/">Documentation</a>		</li>
		<li id="wp-admin-bar-support-forums"><a class="ab-item"  href="http://wordpress.org/support/">Support Forums</a>		</li>
		<li id="wp-admin-bar-feedback"><a class="ab-item"  href="http://wordpress.org/support/forum/requests-and-feedback">Feedback</a>		</li></ul></div>		</li>
		<li id="wp-admin-bar-site-name" class="menupop"><a class="ab-item"  aria-haspopup="true" href="http://blog.fabianobento.com.br/">Fabiano Bento</a><div class="ab-sub-wrapper"><ul id="wp-admin-bar-site-name-default" class="ab-submenu">
		<li id="wp-admin-bar-view-site"><a class="ab-item"  href="http://blog.fabianobento.com.br/">Visit Site</a>		</li></ul></div>		</li>
		<li id="wp-admin-bar-updates"><a class="ab-item"  href="http://blog.fabianobento.com.br/wp-admin/update-core.php" title="1 Plugin Update"><span class="ab-icon"></span><span class="ab-label">1</span><span class="screen-reader-text">1 Plugin Update</span></a>		</li>
		<li id="wp-admin-bar-comments"><a class="ab-item"  href="http://blog.fabianobento.com.br/wp-admin/edit-comments.php" title="4 comments awaiting moderation"><span class="ab-icon"></span><span id="ab-awaiting-mod" class="ab-label awaiting-mod pending-count count-4">4</span></a>		</li>
		<li id="wp-admin-bar-new-content" class="menupop"><a class="ab-item"  aria-haspopup="true" href="http://blog.fabianobento.com.br/wp-admin/post-new.php" title="Add New"><span class="ab-icon"></span><span class="ab-label">New</span></a><div class="ab-sub-wrapper"><ul id="wp-admin-bar-new-content-default" class="ab-submenu">
		<li id="wp-admin-bar-new-post"><a class="ab-item"  href="http://blog.fabianobento.com.br/wp-admin/post-new.php">Post</a>		</li>
		<li id="wp-admin-bar-new-media"><a class="ab-item"  href="http://blog.fabianobento.com.br/wp-admin/media-new.php">Media</a>		</li>
		<li id="wp-admin-bar-new-link"><a class="ab-item"  href="http://blog.fabianobento.com.br/wp-admin/link-add.php">Link</a>		</li>
		<li id="wp-admin-bar-new-page"><a class="ab-item"  href="http://blog.fabianobento.com.br/wp-admin/post-new.php?post_type=page">Page</a>		</li>
		<li id="wp-admin-bar-new-user"><a class="ab-item"  href="http://blog.fabianobento.com.br/wp-admin/user-new.php">User</a>		</li></ul></div>		</li>
		<li id="wp-admin-bar-ngg-menu" class="menupop"><a class="ab-item"  aria-haspopup="true" href="http://blog.fabianobento.com.br/wp-admin/admin.php?page=nextgen-gallery">Gallery</a><div class="ab-sub-wrapper"><ul id="wp-admin-bar-ngg-menu-default" class="ab-submenu">
		<li id="wp-admin-bar-ngg-menu-overview"><a class="ab-item"  href="http://blog.fabianobento.com.br/wp-admin/admin.php?page=nextgen-gallery">Overview</a>		</li>
		<li id="wp-admin-bar-ngg-menu-add-gallery"><a class="ab-item"  href="http://blog.fabianobento.com.br/wp-admin/admin.php?page=ngg_addgallery">Add Gallery / Images</a>		</li>
		<li id="wp-admin-bar-ngg-menu-manage-gallery"><a class="ab-item"  href="http://blog.fabianobento.com.br/wp-admin/admin.php?page=nggallery-manage-gallery">Manage Galleries</a>		</li>
		<li id="wp-admin-bar-ngg-menu-manage-album"><a class="ab-item"  href="http://blog.fabianobento.com.br/wp-admin/admin.php?page=nggallery-manage-album">Manage Albums</a>		</li>
		<li id="wp-admin-bar-ngg-menu-tags"><a class="ab-item"  href="http://blog.fabianobento.com.br/wp-admin/admin.php?page=nggallery-tags">Manage Tags</a>		</li>
		<li id="wp-admin-bar-ngg-menu-display_settings"><a class="ab-item"  href="http://blog.fabianobento.com.br/wp-admin/admin.php?page=ngg_display_settings">Gallery Settings</a>		</li>
		<li id="wp-admin-bar-ngg-menu-other_options"><a class="ab-item"  href="http://blog.fabianobento.com.br/wp-admin/admin.php?page=ngg_other_options">Other Options</a>		</li></ul></div>		</li></ul><ul id="wp-admin-bar-top-secondary" class="ab-top-secondary ab-top-menu">
		<li id="wp-admin-bar-my-account" class="menupop with-avatar"><a class="ab-item"  aria-haspopup="true" href="http://blog.fabianobento.com.br/wp-admin/profile.php" title="My Account">Howdy, Bento<img alt='' src='http://0.gravatar.com/avatar/cfa44b1884f20520e243ced33e679143?s=26&d=blank&r=G' class='avatar avatar-26 photo' height='26' width='26' /></a><div class="ab-sub-wrapper"><ul id="wp-admin-bar-user-actions" class="ab-submenu">
		<li id="wp-admin-bar-user-info"><a class="ab-item" tabindex="-1" href="http://blog.fabianobento.com.br/wp-admin/profile.php"><img alt='' src='http://0.gravatar.com/avatar/cfa44b1884f20520e243ced33e679143?s=64&d=blank&r=G' class='avatar avatar-64 photo' height='64' width='64' /><span class='display-name'>Bento</span><span class='username'>fabiano</span></a>		</li>
		<li id="wp-admin-bar-edit-profile"><a class="ab-item"  href="http://blog.fabianobento.com.br/wp-admin/profile.php">Edit My Profile</a>		</li>
		<li id="wp-admin-bar-logout"><a class="ab-item"  href="http://blog.fabianobento.com.br/wp-login.php?action=logout&_wpnonce=4fc0b78e9d">Log Out</a>		</li></ul></div>		</li></ul>			</div>
						<a class="screen-reader-shortcut" href="http://blog.fabianobento.com.br/wp-login.php?action=logout&_wpnonce=4fc0b78e9d">Log Out</a>
					</div>
 
		</body>
</html>

Artigo original: http://www.zubrag.com/scripts/

Upload de arquivos PHP

Posted by Bento | Posted in Artigos, Desenvolvimento, PHP | Posted on 05-10-2010-05-2008

4

Hoje vou mostrar como fazer upload de arquivos atraves do PHP, para utilizar em outros exemplos que vou postar aqui no blog.

O Upload de arquivos consiste na seleção de um arquivo qualquer no computador do usuário para ser enviado por um formulário HTML, este formulário envia as informações para uma pagina onde copiamos o arquivo do computador local para uma pasta dentro do servidor onde o site está hospedado. Após o upload podemos compactar, renomear, entre muitas outras funções que o PHP oferece.

Crie um arquivo chamado upload.html e coloque dentro o codigo conforme exemplo abaixo.
A action do form esta apontando para o arquivo “upload.php”

1
2
3
4
5
6
7
8
9
10
11
12
<html>
<form id="upload" name="upload" enctype="multipart/form-data" method="post" action="upload.php">
  <p>
    <label>
      <input type="file" name="file" id="file" />
    </label>
  </p>
  <p>
    <input type="submit" name="enviar" id="enviar" value="Enviar arquivo..." />
  </p>
</form>
</html>

Agora vamos criar o arquivo upload.php que fará todo o trabalho.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?php
 
//verificamos se o arquivo foi informado
if (isset($_FILES[file])) {
 
$url = "/pasta-uploads/"; //caminho onse será salvo os arquivos
$carregar = $_FILES[file][tmp_name]; //arquivo temporario
$novo_nome = date('Y-m-d')."_".$_FILES[file][name]; //criamos uma variavel com o novo nome do formato AAAA-MM-DD_nome_arquivo
 
      if(move_uploaded_file($carregar,$url)){   //copia o arquivo do computador para o servidor
         rename($url.$carregar, $url.$novo_nome);//renomeia o arquivo
 
        echo "arquivo enviado com sucesso";
      }else {
                echo "falha ao carregar arquivo";
               }
} else {
         echo "Nenhum arquivo foi selecionado!";
         }
 
?>