No regular expressions were active.
1 |
|
<?
|
|
1 |
|
<?
|
2 |
|
|
|
2 |
|
|
3 |
|
/*********
**********
**********
**********
**********
**********
**********
******
|
|
3 |
|
/*********
**********
**********
**********
**********
**********
**********
******
|
4 |
|
*
D
olphin Sma
rt Communi
ty Builder
|
|
4 |
|
*
D
olphin Sma
rt Communi
ty Builder
|
5 |
|
*
---------
--------
|
|
5 |
|
*
---------
--------
|
6 |
|
* begi
n
: M
on Mar 23
2006
|
|
6 |
|
* begi
n
: M
on Mar 23
2006
|
7 |
|
* copy
right
: (
C) 2006 Bo
onEx Group
|
|
7 |
|
* copy
right
: (
C) 2006 Bo
onEx Group
|
8 |
|
* webs
ite
: h
ttp://www.
boonex.com
/
|
|
8 |
|
* webs
ite
: h
ttp://www.
boonex.com
/
|
9 |
|
* This fil
e is part
of Dolphin
- Smart C
ommunity B
uilder
|
|
9 |
|
* This fil
e is part
of Dolphin
- Smart C
ommunity B
uilder
|
10 |
|
*
|
|
10 |
|
*
|
11 |
|
* Dolphin
is free so
ftware. Th
is work is
licensed
under a Cr
eative Com
mons Attri
bution 3.0
License.
|
|
11 |
|
* Dolphin
is free so
ftware. Th
is work is
licensed
under a Cr
eative Com
mons Attri
bution 3.0
License.
|
12 |
|
* http://c
reativecom
mons.org/l
icenses/by
/3.0/
|
|
12 |
|
* http://c
reativecom
mons.org/l
icenses/by
/3.0/
|
13 |
|
*
|
|
13 |
|
*
|
14 |
|
* Dolphin
is distrib
uted in th
e hope tha
t it will
be useful,
but WITHO
UT ANY WAR
RANTY;
|
|
14 |
|
* Dolphin
is distrib
uted in th
e hope tha
t it will
be useful,
but WITHO
UT ANY WAR
RANTY;
|
15 |
|
* without
even the i
mplied war
ranty of
MERCHANTAB
ILITY or F
ITNESS FOR
A PARTICU
LAR PURPOS
E.
|
|
15 |
|
* without
even the i
mplied war
ranty of
MERCHANTAB
ILITY or F
ITNESS FOR
A PARTICU
LAR PURPOS
E.
|
16 |
|
* See the
Creative C
ommons Att
ribution 3
.0 License
for more
details.
|
|
16 |
|
* See the
Creative C
ommons Att
ribution 3
.0 License
for more
details.
|
17 |
|
* You shou
ld have re
ceived a c
opy of the
Creative
Commons At
tribution
3.0 Licens
e along wi
th Dolphin
,
|
|
17 |
|
* You shou
ld have re
ceived a c
opy of the
Creative
Commons At
tribution
3.0 Licens
e along wi
th Dolphin
,
|
18 |
|
* see lice
nse.txt fi
le; if not
, write to
marketing
@boonex.co
m
|
|
18 |
|
* see lice
nse.txt fi
le; if not
, write to
marketing
@boonex.co
m
|
19 |
|
**********
**********
**********
**********
**********
**********
**********
*****/
|
|
19 |
|
**********
**********
**********
**********
**********
**********
**********
*****/
|
20 |
|
|
|
20 |
|
|
21 |
|
require_on
ce( 'heade
r.inc.php'
);
|
|
21 |
|
require_on
ce( 'heade
r.inc.php'
);
|
22 |
|
require_on
ce( BX_DIR
ECTORY_PAT
H_INC . 'd
b.inc.php'
);
|
|
22 |
|
require_on
ce( BX_DIR
ECTORY_PAT
H_INC . 'd
b.inc.php'
);
|
23 |
|
require_on
ce( BX_DIR
ECTORY_PAT
H_INC . 'p
arams.inc.
php' );
|
|
23 |
|
require_on
ce( BX_DIR
ECTORY_PAT
H_INC . 'p
arams.inc.
php' );
|
24 |
|
|
|
24 |
|
|
25 |
|
$gdInstall
ed = exten
sion_loade
d( 'gd' );
|
|
25 |
|
$gdInstall
ed = exten
sion_loade
d( 'gd' );
|
26 |
|
$use_gd =
getParam(
'enable_gd
' ) == 'on
' ? 1 : 0;
|
|
26 |
|
$use_gd =
getParam(
'enable_gd
' ) == 'on
' ? 1 : 0;
|
27 |
|
|
|
27 |
|
|
28 |
|
// Functio
n error co
des
|
|
28 |
|
// Functio
n error co
des
|
29 |
|
define( 'I
MAGE_ERROR
_SUCCESS',
0
);
|
|
29 |
|
define( 'I
MAGE_ERROR
_SUCCESS',
0
);
|
30 |
|
define( 'I
MAGE_ERROR
_SOURCE_NO
T_EXISTS',
1
);
|
|
30 |
|
define( 'I
MAGE_ERROR
_SOURCE_NO
T_EXISTS',
1
);
|
31 |
|
define( 'I
MAGE_ERROR
_WRONG_TYP
E',
2
);
|
|
31 |
|
define( 'I
MAGE_ERROR
_WRONG_TYP
E',
2
);
|
32 |
|
define( 'I
MAGE_ERROR
_FILE_OPEN
_FAILED',
3
);
|
|
32 |
|
define( 'I
MAGE_ERROR
_FILE_OPEN
_FAILED',
3
);
|
33 |
|
define( 'I
MAGE_ERROR
_IMAGEMAGI
CK_ERROR',
4
);
|
|
33 |
|
define( 'I
MAGE_ERROR
_IMAGEMAGI
CK_ERROR',
4
);
|
34 |
|
define( 'I
MAGE_ERROR
_GD_NOT_IN
STALLED',
5
);
|
|
34 |
|
define( 'I
MAGE_ERROR
_GD_NOT_IN
STALLED',
5
);
|
35 |
|
define( 'I
MAGE_ERROR
_GD_TYPE_N
OT_SUPPORT
ED', 6
);
|
|
35 |
|
define( 'I
MAGE_ERROR
_GD_TYPE_N
OT_SUPPORT
ED', 6
);
|
36 |
|
define( 'I
MAGE_ERROR
_GD_OPEN_F
AILED',
7
);
|
|
36 |
|
define( 'I
MAGE_ERROR
_GD_OPEN_F
AILED',
7
);
|
37 |
|
define( 'I
MAGE_ERROR
_GD_RESIZE
_ERROR',
8
);
|
|
37 |
|
define( 'I
MAGE_ERROR
_GD_RESIZE
_ERROR',
8
);
|
38 |
|
define( 'I
MAGE_ERROR
_GD_MERGE_
ERROR',
9
);
|
|
38 |
|
define( 'I
MAGE_ERROR
_GD_MERGE_
ERROR',
9
);
|
39 |
|
define( 'I
MAGE_ERROR
_GD_WRITE_
FAILED',
10
);
|
|
39 |
|
define( 'I
MAGE_ERROR
_GD_WRITE_
FAILED',
10
);
|
40 |
|
define( 'I
MAGE_ERROR
_GD_TTF_NO
T_SUPPORTE
D', 11
);
|
|
40 |
|
define( 'I
MAGE_ERROR
_GD_TTF_NO
T_SUPPORTE
D', 11
);
|
41 |
|
|
|
41 |
|
|
42 |
|
|
|
42 |
|
|
43 |
|
// Image t
ypes for G
D
|
|
43 |
|
// Image t
ypes for G
D
|
44 |
|
// NOTE: a
ctually th
ese consta
nts exist
in PHP >=
4.3.0, but
they are
included f
or
|
|
44 |
|
// NOTE: a
ctually th
ese consta
nts exist
in PHP >=
4.3.0, but
they are
included f
or
|
45 |
|
// b
ack compat
ibility
|
|
45 |
|
// b
ack compat
ibility
|
46 |
|
define( 'I
MAGE_TYPE_
GIF',
1 );
|
|
46 |
|
define( 'I
MAGE_TYPE_
GIF',
1 );
|
47 |
|
define( 'I
MAGE_TYPE_
JPG',
2 );
|
|
47 |
|
define( 'I
MAGE_TYPE_
JPG',
2 );
|
48 |
|
define( 'I
MAGE_TYPE_
PNG',
3 );
|
|
48 |
|
define( 'I
MAGE_TYPE_
PNG',
3 );
|
49 |
|
|
|
49 |
|
|
50 |
|
/**
|
|
50 |
|
/**
|
51 |
|
* Resizes
image giv
en in $src
Filename t
o dimensio
ns specifi
ed with $s
izeX x $si
zeY and
|
|
51 |
|
* Resizes
image giv
en in $src
Filename t
o dimensio
ns specifi
ed with $s
izeX x $si
zeY and
|
52 |
|
* saves i
t to $dstF
ilename
|
|
52 |
|
* saves i
t to $dstF
ilename
|
53 |
|
*
|
|
53 |
|
*
|
54 |
|
* @param
string $sr
cFilename
- source i
mage filen
ame
|
|
54 |
|
* @param
string $sr
cFilename
- source i
mage filen
ame
|
55 |
|
* @param
string $ds
tFilename
- destinat
ion image
filename
|
|
55 |
|
* @param
string $ds
tFilename
- destinat
ion image
filename
|
56 |
|
* @param
int $sizeX
- width of
destinati
on image
|
|
56 |
|
* @param
int $sizeX
- width of
destinati
on image
|
57 |
|
* @param
int $sizeY
- height o
f destinat
ion image
|
|
57 |
|
* @param
int $sizeY
- height o
f destinat
ion image
|
58 |
|
* @param
bool $forc
eJPGOutput
- always m
ake result
in JPG fo
rmat
|
|
58 |
|
* @param
bool $forc
eJPGOutput
- always m
ake result
in JPG fo
rmat
|
59 |
|
*
|
|
59 |
|
*
|
60 |
|
* @return
int
- zero on
success, n
on-zero on
fail
|
|
60 |
|
* @return
int
- zero on
success, n
on-zero on
fail
|
61 |
|
*
|
|
61 |
|
*
|
62 |
|
*
|
|
62 |
|
*
|
63 |
|
* NOTE: S
ource imag
e should b
e in GIF,
JPEG or PN
G format
|
|
63 |
|
* NOTE: S
ource imag
e should b
e in GIF,
JPEG or PN
G format
|
64 |
|
*/
|
|
64 |
|
*/
|
65 |
|
function i
mageResize
( $srcFile
name, $dst
Filename,
$sizeX, $s
izeY, $for
ceJPGOutpu
t = false
)
|
|
65 |
|
function i
mageResize
( $srcFile
name, $dst
Filename,
$sizeX, $s
izeY, $for
ceJPGOutpu
t = false
)
|
66 |
|
{
|
|
66 |
|
{
|
67 |
|
global
$use_gd;
|
|
67 |
|
global
$use_gd;
|
68 |
|
global
$CONVERT;
|
|
68 |
|
global
$CONVERT;
|
69 |
|
global
$MOGRIFY;
|
|
69 |
|
global
$MOGRIFY;
|
70 |
|
global
$gdInstal
led;
|
|
70 |
|
global
$gdInstal
led;
|
71 |
|
|
|
71 |
|
|
72 |
|
// inp
ut validat
ion
|
|
72 |
|
// inp
ut validat
ion
|
73 |
|
$sizeX
= (int) $
sizeX;
|
|
73 |
|
$sizeX
= (int) $
sizeX;
|
74 |
|
$sizeY
= (int) $
sizeY;
|
|
74 |
|
$sizeY
= (int) $
sizeY;
|
75 |
|
if ( !
file_exist
s( $srcFil
ename ) )
|
|
75 |
|
if ( !
file_exist
s( $srcFil
ename ) )
|
76 |
|
re
turn IMAGE
_ERROR_SOU
RCE_NOT_EX
ISTS;
|
|
76 |
|
re
turn IMAGE
_ERROR_SOU
RCE_NOT_EX
ISTS;
|
77 |
|
|
|
77 |
|
|
78 |
|
// if
destinatio
n and sour
ce filenam
es are equ
ivalent th
en change
mode for d
estination
|
|
78 |
|
// if
destinatio
n and sour
ce filenam
es are equ
ivalent th
en change
mode for d
estination
|
79 |
|
if ( $
srcFilenam
e == $dstF
ilename )
|
|
79 |
|
if ( $
srcFilenam
e == $dstF
ilename )
|
80 |
|
ch
mod( $dstF
ilename, 0
666 );
|
|
80 |
|
ch
mod( $dstF
ilename, 0
666 );
|
81 |
|
|
|
81 |
|
|
82 |
|
if ( $
use_gd )
|
|
82 |
|
if ( $
use_gd )
|
83 |
|
{
|
|
83 |
|
{
|
84 |
|
if
( !$gdIns
talled )
|
|
84 |
|
if
( !$gdIns
talled )
|
85 |
|
return I
MAGE_ERROR
_GD_NOT_IN
STALLED;
|
|
85 |
|
return I
MAGE_ERROR
_GD_NOT_IN
STALLED;
|
86 |
|
$g
dInfoArray
= gd_info
();
|
|
86 |
|
$g
dInfoArray
= gd_info
();
|
87 |
|
$s
ize = geti
magesize(
$srcFilena
me );
|
|
87 |
|
$s
ize = geti
magesize(
$srcFilena
me );
|
88 |
|
|
|
88 |
|
|
89 |
|
//
only GIF,
JPG and P
NG allowed
|
|
89 |
|
//
only GIF,
JPG and P
NG allowed
|
90 |
|
sw
itch ( $si
ze[2] )
|
|
90 |
|
sw
itch ( $si
ze[2] )
|
91 |
|
{
|
|
91 |
|
{
|
92 |
|
case IMA
GE_TYPE_GI
F:
|
|
92 |
|
case IMA
GE_TYPE_GI
F:
|
93 |
|
if (
!$gdInfoA
rray['GIF
Read Suppo
rt'] || !$
gdInfoArra
y['GIF Cre
ate Suppor
t'] )
|
|
93 |
|
if (
!$gdInfoA
rray['GIF
Read Suppo
rt'] || !$
gdInfoArra
y['GIF Cre
ate Suppor
t'] )
|
94 |
|
return IMA
GE_ERROR_G
D_TYPE_NOT
_SUPPORTED
;
|
|
94 |
|
return IMA
GE_ERROR_G
D_TYPE_NOT
_SUPPORTED
;
|
95 |
|
$src
_im = @ima
gecreatefr
omgif( $sr
cFilename
);
|
|
95 |
|
$src
_im = @ima
gecreatefr
omgif( $sr
cFilename
);
|
96 |
|
brea
k;
|
|
96 |
|
brea
k;
|
97 |
|
case IMA
GE_TYPE_JP
G:
|
|
97 |
|
case IMA
GE_TYPE_JP
G:
|
98 |
|
if (
!$gdInfoA
rray['JPG
Support']
)
|
|
98 |
|
if (
!$gdInfoA
rray['JPG
Support']
)
|
99 |
|
return IMA
GE_ERROR_G
D_TYPE_NOT
_SUPPORTED
;
|
|
99 |
|
return IMA
GE_ERROR_G
D_TYPE_NOT
_SUPPORTED
;
|
100 |
|
$src
_im = @ima
gecreatefr
omjpeg( $s
rcFilename
);
|
|
100 |
|
$src
_im = @ima
gecreatefr
omjpeg( $s
rcFilename
);
|
101 |
|
brea
k;
|
|
101 |
|
brea
k;
|
102 |
|
case IMA
GE_TYPE_PN
G:
|
|
102 |
|
case IMA
GE_TYPE_PN
G:
|
103 |
|
if (
!$gdInfoA
rray['PNG
Support']
)
|
|
103 |
|
if (
!$gdInfoA
rray['PNG
Support']
)
|
104 |
|
return IMA
GE_ERROR_G
D_TYPE_NOT
_SUPPORTED
;
|
|
104 |
|
return IMA
GE_ERROR_G
D_TYPE_NOT
_SUPPORTED
;
|
105 |
|
$src
_im = @ima
gecreatefr
ompng( $sr
cFilename
);
|
|
105 |
|
$src
_im = @ima
gecreatefr
ompng( $sr
cFilename
);
|
106 |
|
brea
k;
|
|
106 |
|
brea
k;
|
107 |
|
default:
|
|
107 |
|
default:
|
108 |
|
retu
rn IMAGE_E
RROR_WRONG
_TYPE;
|
|
108 |
|
retu
rn IMAGE_E
RROR_WRONG
_TYPE;
|
109 |
|
}
|
|
109 |
|
}
|
110 |
|
|
|
110 |
|
|
111 |
|
if
( !$src_i
m )
|
|
111 |
|
if
( !$src_i
m )
|
112 |
|
return I
MAGE_ERROR
_GD_OPEN_F
AILED;
|
|
112 |
|
return I
MAGE_ERROR
_GD_OPEN_F
AILED;
|
113 |
|
|
|
113 |
|
|
114 |
|
//
determ de
stination
size
|
|
114 |
|
//
determ de
stination
size
|
115 |
|
$s
ourceRatio
= (float)
($size[0]
/ $size[1
]);
|
|
115 |
|
$s
ourceRatio
= (float)
($size[0]
/ $size[1
]);
|
116 |
|
$d
estRatio =
(float) (
$sizeX / $
sizeY);
|
|
116 |
|
$d
estRatio =
(float) (
$sizeX / $
sizeY);
|
117 |
|
if
( $source
Ratio > $d
estRatio )
|
|
117 |
|
if
( $source
Ratio > $d
estRatio )
|
118 |
|
{
|
|
118 |
|
{
|
119 |
|
$resizeR
atio = (fl
oat) ($siz
eX / $size
[0]);
|
|
119 |
|
$resizeR
atio = (fl
oat) ($siz
eX / $size
[0]);
|
120 |
|
}
|
|
120 |
|
}
|
121 |
|
el
se
|
|
121 |
|
el
se
|
122 |
|
{
|
|
122 |
|
{
|
123 |
|
$resizeR
atio = (fl
oat) ($siz
eY / $size
[1]);
|
|
123 |
|
$resizeR
atio = (fl
oat) ($siz
eY / $size
[1]);
|
124 |
|
}
|
|
124 |
|
}
|
125 |
|
$d
estX = (in
t) ($resiz
eRatio * $
size[0]);
|
|
125 |
|
$d
estX = (in
t) ($resiz
eRatio * $
size[0]);
|
126 |
|
$d
estY = (in
t) ($resiz
eRatio * $
size[1]);
|
|
126 |
|
$d
estY = (in
t) ($resiz
eRatio * $
size[1]);
|
127 |
|
|
|
127 |
|
|
128 |
|
//
this is m
ore qualit
ative func
tion, but
it doesn't
exist in
old GD and
doesn't s
upport GIF
format
|
|
128 |
|
//
this is m
ore qualit
ative func
tion, but
it doesn't
exist in
old GD and
doesn't s
upport GIF
format
|
129 |
|
if
( functio
n_exists(
'imagecrea
tetruecolo
r' ) && $s
ize[2] !=
IMAGE_TYPE
_GIF )
|
|
129 |
|
if
( functio
n_exists(
'imagecrea
tetruecolo
r' ) && $s
ize[2] !=
IMAGE_TYPE
_GIF )
|
130 |
|
{
|
|
130 |
|
{
|
131 |
|
// resiz
e only if
size is la
rger than
needed
|
|
131 |
|
// resiz
e only if
size is la
rger than
needed
|
132 |
|
if ( $si
ze[0] > $s
izeX || $s
ize[1] > $
sizeY )
|
|
132 |
|
if ( $si
ze[0] > $s
izeX || $s
ize[1] > $
sizeY )
|
133 |
|
{
|
|
133 |
|
{
|
134 |
|
$dst
_im = imag
ecreatetru
ecolor( $d
estX, $des
tY );
|
|
134 |
|
$dst
_im = imag
ecreatetru
ecolor( $d
estX, $des
tY );
|
135 |
|
$con
vertResult
= imageco
pyresample
d( $dst_im
, $src_im,
0, 0, 0,
0,
|
|
135 |
|
$con
vertResult
= imageco
pyresample
d( $dst_im
, $src_im,
0, 0, 0,
0,
|
136 |
|
$destX, $d
estY, $siz
e[0], $siz
e[1] );
|
|
136 |
|
$destX, $d
estY, $siz
e[0], $siz
e[1] );
|
137 |
|
}
|
|
137 |
|
}
|
138 |
|
else
|
|
138 |
|
else
|
139 |
|
{
|
|
139 |
|
{
|
140 |
|
$dst
_im = $src
_im;
|
|
140 |
|
$dst
_im = $src
_im;
|
141 |
|
$con
vertResult
= true;
|
|
141 |
|
$con
vertResult
= true;
|
142 |
|
}
|
|
142 |
|
}
|
143 |
|
}
|
|
143 |
|
}
|
144 |
|
el
se // this
is for ol
d GD versi
ons and fo
r GIF imag
es
|
|
144 |
|
el
se // this
is for ol
d GD versi
ons and fo
r GIF imag
es
|
145 |
|
{
|
|
145 |
|
{
|
146 |
|
// resiz
e only if
size is la
rger than
needed
|
|
146 |
|
// resiz
e only if
size is la
rger than
needed
|
147 |
|
if ( $si
ze[0] > $s
izeX || $s
ize[1] > $
sizeY )
|
|
147 |
|
if ( $si
ze[0] > $s
izeX || $s
ize[1] > $
sizeY )
|
148 |
|
{
|
|
148 |
|
{
|
149 |
|
$dst
_im = imag
ecreate( $
destX, $de
stY );
|
|
149 |
|
$dst
_im = imag
ecreate( $
destX, $de
stY );
|
150 |
|
$con
vertResult
= imageco
pyresized(
$dst_im,
$src_im, 0
, 0, 0, 0,
|
|
150 |
|
$con
vertResult
= imageco
pyresized(
$dst_im,
$src_im, 0
, 0, 0, 0,
|
151 |
|
$destX, $d
estY, $siz
e[0], $siz
e[1] );
|
|
151 |
|
$destX, $d
estY, $siz
e[0], $siz
e[1] );
|
152 |
|
}
|
|
152 |
|
}
|
153 |
|
else
|
|
153 |
|
else
|
154 |
|
{
|
|
154 |
|
{
|
155 |
|
$dst
_im = $src
_im;
|
|
155 |
|
$dst
_im = $src
_im;
|
156 |
|
$con
vertResult
= true;
|
|
156 |
|
$con
vertResult
= true;
|
157 |
|
}
|
|
157 |
|
}
|
158 |
|
}
|
|
158 |
|
}
|
159 |
|
|
|
159 |
|
|
160 |
|
if
( !$conve
rtResult )
|
|
160 |
|
if
( !$conve
rtResult )
|
161 |
|
return I
MAGE_ERROR
_GD_RESIZE
_ERROR;
|
|
161 |
|
return I
MAGE_ERROR
_GD_RESIZE
_ERROR;
|
162 |
|
|
|
162 |
|
|
163 |
|
//
if output
always in
JPG
|
|
163 |
|
//
if output
always in
JPG
|
164 |
|
if
( $forceJ
PGOutput )
|
|
164 |
|
if
( $forceJ
PGOutput )
|
165 |
|
{
|
|
165 |
|
{
|
166 |
|
$writeRe
sult = ima
gejpeg( $d
st_im, $ds
tFilename
);
|
|
166 |
|
$writeRe
sult = ima
gejpeg( $d
st_im, $ds
tFilename
);
|
167 |
|
}
|
|
167 |
|
}
|
168 |
|
el
se // othe
rwise
|
|
168 |
|
el
se // othe
rwise
|
169 |
|
{
|
|
169 |
|
{
|
170 |
|
switch (
$size[2]
)
|
|
170 |
|
switch (
$size[2]
)
|
171 |
|
{
|
|
171 |
|
{
|
172 |
|
case
IMAGE_TYP
E_GIF:
|
|
172 |
|
case
IMAGE_TYP
E_GIF:
|
173 |
|
$writeResu
lt = image
gif( $dst_
im, $dstFi
lename );
|
|
173 |
|
$writeResu
lt = image
gif( $dst_
im, $dstFi
lename );
|
174 |
|
break;
|
|
174 |
|
break;
|
175 |
|
case
IMAGE_TYP
E_JPG:
|
|
175 |
|
case
IMAGE_TYP
E_JPG:
|
176 |
|
$writeResu
lt = image
jpeg( $dst
_im, $dstF
ilename );
|
|
176 |
|
$writeResu
lt = image
jpeg( $dst
_im, $dstF
ilename );
|
177 |
|
break;
|
|
177 |
|
break;
|
178 |
|
case
IMAGE_TYP
E_PNG:
|
|
178 |
|
case
IMAGE_TYP
E_PNG:
|
179 |
|
$writeResu
lt = image
png( $dst_
im, $dstFi
lename );
|
|
179 |
|
$writeResu
lt = image
png( $dst_
im, $dstFi
lename );
|
180 |
|
break;
|
|
180 |
|
break;
|
181 |
|
}
|
|
181 |
|
}
|
182 |
|
}
|
|
182 |
|
}
|
183 |
|
|
|
183 |
|
|
184 |
|
//
free memo
ry
|
|
184 |
|
//
free memo
ry
|
185 |
|
if
( $dst_im
!= $src_i
m )
|
|
185 |
|
if
( $dst_im
!= $src_i
m )
|
186 |
|
{
|
|
186 |
|
{
|
187 |
|
imagedes
troy( $src
_im );
|
|
187 |
|
imagedes
troy( $src
_im );
|
188 |
|
imagedes
troy( $dst
_im );
|
|
188 |
|
imagedes
troy( $dst
_im );
|
189 |
|
}
|
|
189 |
|
}
|
190 |
|
el
se
|
|
190 |
|
el
se
|
191 |
|
{
|
|
191 |
|
{
|
192 |
|
imagedes
troy( $src
_im );
|
|
192 |
|
imagedes
troy( $src
_im );
|
193 |
|
}
|
|
193 |
|
}
|
194 |
|
|
|
194 |
|
|
195 |
|
if
( $writeR
esult && f
ile_exists
($dstFilen
ame) )
|
|
195 |
|
if
( $writeR
esult && f
ile_exists
($dstFilen
ame) )
|
196 |
|
return I
MAGE_ERROR
_SUCCESS;
|
|
196 |
|
return I
MAGE_ERROR
_SUCCESS;
|
197 |
|
el
se
|
|
197 |
|
el
se
|
198 |
|
return I
MAGE_ERROR
_GD_WRITE_
FAILED;
|
|
198 |
|
return I
MAGE_ERROR
_GD_WRITE_
FAILED;
|
199 |
|
}
|
|
199 |
|
}
|
200 |
|
else
|
|
200 |
|
else
|
201 |
|
{
|
|
201 |
|
{
|
202 |
|
if
( $srcFil
ename == $
dstFilenam
e )
|
|
202 |
|
if
( $srcFil
ename == $
dstFilenam
e )
|
203 |
|
{
|
|
203 |
|
{
|
204 |
|
$cmd = "
$MOGRIFY -
geometry {
$sizeX}\">
\"x{$sizeY
}\">\" $sr
cFilename"
;
|
|
204 |
|
$cmd = "
$MOGRIFY -
geometry {
$sizeX}\">
\"x{$sizeY
}\">\" $sr
cFilename"
;
|
205 |
|
@exec( $
cmd );
|
|
205 |
|
@exec( $
cmd );
|
206 |
|
$ext = s
trrchr($sr
cFilename,
'.');
|
|
206 |
|
$ext = s
trrchr($sr
cFilename,
'.');
|
207 |
|
$nameWit
houtExt =
substr( $s
rcFilename
, 0, strrp
os($srcFil
ename, '.'
) );
|
|
207 |
|
$nameWit
houtExt =
substr( $s
rcFilename
, 0, strrp
os($srcFil
ename, '.'
) );
|
208 |
|
if ( fil
e_exists(
"{$nameWit
houtExt}.m
gk" ) )
|
|
208 |
|
if ( fil
e_exists(
"{$nameWit
houtExt}.m
gk" ) )
|
209 |
|
rena
me( "{$nam
eWithoutEx
t}.mgk", $
srcFilenam
e );
|
|
209 |
|
rena
me( "{$nam
eWithoutEx
t}.mgk", $
srcFilenam
e );
|
210 |
|
}
|
|
210 |
|
}
|
211 |
|
el
se
|
|
211 |
|
el
se
|
212 |
|
{
|
|
212 |
|
{
|
213 |
|
$cmd = "
$CONVERT $
srcFilenam
e -geometr
y {$sizeX}
\">\"x{$si
zeY}\">\"
$dstFilena
me";
|
|
213 |
|
$cmd = "
$CONVERT $
srcFilenam
e -geometr
y {$sizeX}
\">\"x{$si
zeY}\">\"
$dstFilena
me";
|
214 |
|
@exec( $
cmd );
|
|
214 |
|
@exec( $
cmd );
|
215 |
|
}
|
|
215 |
|
}
|
216 |
|
|
|
216 |
|
|
217 |
|
if
( file_ex
ists($dstF
ilename) )
|
|
217 |
|
if
( file_ex
ists($dstF
ilename) )
|
218 |
|
return I
MAGE_ERROR
_SUCCESS;
|
|
218 |
|
return I
MAGE_ERROR
_SUCCESS;
|
219 |
|
el
se
|
|
219 |
|
el
se
|
220 |
|
return I
MAGE_ERROR
_IMAGEMAGI
CK_ERROR;
|
|
220 |
|
return I
MAGE_ERROR
_IMAGEMAGI
CK_ERROR;
|
221 |
|
}
|
|
221 |
|
}
|
222 |
|
}
|
|
222 |
|
}
|
223 |
|
|
|
223 |
|
|
224 |
|
/**
|
|
224 |
|
/**
|
225 |
|
* Sends P
NG image h
eader to b
rowser and
produces
security i
mage with
text, spec
ified in
|
|
225 |
|
* Sends P
NG image h
eader to b
rowser and
produces
security i
mage with
text, spec
ified in
|
226 |
|
* $text p
arameter
|
|
226 |
|
* $text p
arameter
|
227 |
|
*
|
|
227 |
|
*
|
228 |
|
* @param
string $te
xt
- text to
output on
security i
mage
|
|
228 |
|
* @param
string $te
xt
- text to
output on
security i
mage
|
229 |
|
* @param
string $ha
sh
- MD5 hash
for $text
parameter
|
|
229 |
|
* @param
string $ha
sh
- MD5 hash
for $text
parameter
|
230 |
|
*
|
|
230 |
|
*
|
231 |
|
* @return
int
- zero on
success, n
on-zero on
fail
|
|
231 |
|
* @return
int
- zero on
success, n
on-zero on
fail
|
232 |
|
*
|
|
232 |
|
*
|
233 |
|
* NOTE: S
ource imag
e should b
e in GIF,
JPEG or PN
G format
|
|
233 |
|
* NOTE: S
ource imag
e should b
e in GIF,
JPEG or PN
G format
|
234 |
|
*/
|
|
234 |
|
*/
|
235 |
|
function p
roduceSecu
rityImage(
$text, $h
ash )
|
|
235 |
|
function p
roduceSecu
rityImage(
$text, $h
ash )
|
236 |
|
{
|
|
236 |
|
{
|
237 |
|
global
$use_gd;
|
|
237 |
|
global
$use_gd;
|
238 |
|
global
$CONVERT;
|
|
238 |
|
global
$CONVERT;
|
239 |
|
global
$gdInstal
led;
|
|
239 |
|
global
$gdInstal
led;
|
240 |
|
global
$dir;
|
|
240 |
|
global
$dir;
|
241 |
|
|
|
241 |
|
|
242 |
|
// con
stant valu
es
|
|
242 |
|
// con
stant valu
es
|
243 |
|
$backg
roundSizeX
= 2000;
|
|
243 |
|
$backg
roundSizeX
= 2000;
|
244 |
|
$backg
roundSizeY
= 350;
|
|
244 |
|
$backg
roundSizeY
= 350;
|
245 |
|
$sizeX
= 200;
|
|
245 |
|
$sizeX
= 200;
|
246 |
|
$sizeY
= 35;
|
|
246 |
|
$sizeY
= 35;
|
247 |
|
$fontF
ile = "{$d
ir['root']
}simg/verd
ana.ttf";
|
|
247 |
|
$fontF
ile = "{$d
ir['root']
}simg/verd
ana.ttf";
|
248 |
|
$textL
ength = st
rlen( $tex
t );
|
|
248 |
|
$textL
ength = st
rlen( $tex
t );
|
249 |
|
|
|
249 |
|
|
250 |
|
// gen
erate rand
om securit
y values
|
|
250 |
|
// gen
erate rand
om securit
y values
|
251 |
|
$backg
roundIndex
= rand( 1
, 3 );
|
|
251 |
|
$backg
roundIndex
= rand( 1
, 3 );
|
252 |
|
$backg
roundOffse
tX = rand(
0, $backg
roundSizeX
- $sizeX
- 1 );
|
|
252 |
|
$backg
roundOffse
tX = rand(
0, $backg
roundSizeX
- $sizeX
- 1 );
|
253 |
|
$backg
roundOffse
tY = rand(
0, $backg
roundSizeY
- $sizeY
- 1 );
|
|
253 |
|
$backg
roundOffse
tY = rand(
0, $backg
roundSizeY
- $sizeY
- 1 );
|
254 |
|
$angle
= rand( -
3, 3 );
|
|
254 |
|
$angle
= rand( -
3, 3 );
|
255 |
|
$fontC
olorR = ra
nd( 0, 127
);
|
|
255 |
|
$fontC
olorR = ra
nd( 0, 127
);
|
256 |
|
$fontC
olorG = ra
nd( 0, 127
);
|
|
256 |
|
$fontC
olorG = ra
nd( 0, 127
);
|
257 |
|
$fontC
olorB = ra
nd( 0, 127
);
|
|
257 |
|
$fontC
olorB = ra
nd( 0, 127
);
|
258 |
|
// thi
s are libr
ary depend
ing parame
ters
|
|
258 |
|
// thi
s are libr
ary depend
ing parame
ters
|
259 |
|
if ( $
use_gd )
|
|
259 |
|
if ( $
use_gd )
|
260 |
|
{
|
|
260 |
|
{
|
261 |
|
$f
ontSize =
rand( 14,
24 );
|
|
261 |
|
$f
ontSize =
rand( 14,
24 );
|
262 |
|
$t
extX = ran
d( 0, (int
)($sizeX -
0.9 * $te
xtLength *
$fontSize
) ); // th
ese coeffi
cients are
empiric
|
|
262 |
|
$t
extX = ran
d( 0, (int
)($sizeX -
0.9 * $te
xtLength *
$fontSize
) ); // th
ese coeffi
cients are
empiric
|
263 |
|
$t
extY = ran
d( (int)(1
.25 * $fon
tSize), (i
nt)($sizeY
- 0.2 * $
fontSize)
); // don'
t try to l
earn how t
hey were t
aken out
|
|
263 |
|
$t
extY = ran
d( (int)(1
.25 * $fon
tSize), (i
nt)($sizeY
- 0.2 * $
fontSize)
); // don'
t try to l
earn how t
hey were t
aken out
|
264 |
|
}
|
|
264 |
|
}
|
265 |
|
else
|
|
265 |
|
else
|
266 |
|
{
|
|
266 |
|
{
|
267 |
|
$f
ontSize =
rand( 14,
28 );
|
|
267 |
|
$f
ontSize =
rand( 14,
28 );
|
268 |
|
$t
extX = ran
d( 0, (int
)($sizeX -
0.68 * $t
extLength
* $fontSiz
e) ); // t
hese coeff
icients ar
e empiric
|
|
268 |
|
$t
extX = ran
d( 0, (int
)($sizeX -
0.68 * $t
extLength
* $fontSiz
e) ); // t
hese coeff
icients ar
e empiric
|
269 |
|
$t
extY = ran
d( 0, (int
)($sizeY -
1.4 * $fo
ntSize) );
// don't
try to lea
rn how the
y were tak
en out
|
|
269 |
|
$t
extY = ran
d( 0, (int
)($sizeY -
1.4 * $fo
ntSize) );
// don't
try to lea
rn how the
y were tak
en out
|
270 |
|
}
|
|
270 |
|
}
|
271 |
|
|
|
271 |
|
|
272 |
|
if ( $
use_gd )
|
|
272 |
|
if ( $
use_gd )
|
273 |
|
{
|
|
273 |
|
{
|
274 |
|
if
( !$gdIns
talled )
|
|
274 |
|
if
( !$gdIns
talled )
|
275 |
|
return I
MAGE_ERROR
_GD_NOT_IN
STALLED;
|
|
275 |
|
return I
MAGE_ERROR
_GD_NOT_IN
STALLED;
|
276 |
|
$g
dInfoArray
= gd_info
();
|
|
276 |
|
$g
dInfoArray
= gd_info
();
|
277 |
|
if
( !$gdInf
oArray['PN
G Support'
] )
|
|
277 |
|
if
( !$gdInf
oArray['PN
G Support'
] )
|
278 |
|
return I
MAGE_ERROR
_GD_TYPE_N
OT_SUPPORT
ED;
|
|
278 |
|
return I
MAGE_ERROR
_GD_TYPE_N
OT_SUPPORT
ED;
|
279 |
|
|
|
279 |
|
|
280 |
|
//
create im
age with b
ackground
|
|
280 |
|
//
create im
age with b
ackground
|
281 |
|
$s
rc_im = im
agecreatef
rompng( "{
$dir['root
']}simg/im
ages/bg{$b
ackgroundI
ndex}.png"
);
|
|
281 |
|
$s
rc_im = im
agecreatef
rompng( "{
$dir['root
']}simg/im
ages/bg{$b
ackgroundI
ndex}.png"
);
|
282 |
|
if
( functio
n_exists(
'imagecrea
tetruecolo
r' ) )
|
|
282 |
|
if
( functio
n_exists(
'imagecrea
tetruecolo
r' ) )
|
283 |
|
{
|
|
283 |
|
{
|
284 |
|
// this
is more qu
alitative
function,
but it doe
sn't exist
in old GD
|
|
284 |
|
// this
is more qu
alitative
function,
but it doe
sn't exist
in old GD
|
285 |
|
$dst_im
= imagecre
atetruecol
or( $sizeX
, $sizeY )
;
|
|
285 |
|
$dst_im
= imagecre
atetruecol
or( $sizeX
, $sizeY )
;
|
286 |
|
$resizeR
esult = im
agecopyres
ampled( $d
st_im, $sr
c_im, 0, 0
, $backgro
undOffsetX
, $backgro
undOffsetY
,
|
|
286 |
|
$resizeR
esult = im
agecopyres
ampled( $d
st_im, $sr
c_im, 0, 0
, $backgro
undOffsetX
, $backgro
undOffsetY
,
|
287 |
|
$siz
eX, $sizeY
, $sizeX,
$sizeY );
|
|
287 |
|
$siz
eX, $sizeY
, $sizeX,
$sizeY );
|
288 |
|
}
|
|
288 |
|
}
|
289 |
|
el
se
|
|
289 |
|
el
se
|
290 |
|
{
|
|
290 |
|
{
|
291 |
|
// this
is for old
GD versio
ns
|
|
291 |
|
// this
is for old
GD versio
ns
|
292 |
|
$dst_im
= imagecre
ate( $size
X, $sizeY
);
|
|
292 |
|
$dst_im
= imagecre
ate( $size
X, $sizeY
);
|
293 |
|
$resizeR
esult = im
agecopyres
ized( $dst
_im, $src_
im, 0, 0,
$backgroun
dOffsetX,
$backgroun
dOffsetY,
|
|
293 |
|
$resizeR
esult = im
agecopyres
ized( $dst
_im, $src_
im, 0, 0,
$backgroun
dOffsetX,
$backgroun
dOffsetY,
|
294 |
|
$siz
eX, $sizeY
, $sizeX,
$sizeY );
|
|
294 |
|
$siz
eX, $sizeY
, $sizeX,
$sizeY );
|
295 |
|
}
|
|
295 |
|
}
|
296 |
|
if
( !$resiz
eResult )
|
|
296 |
|
if
( !$resiz
eResult )
|
297 |
|
return I
MAGE_ERROR
_GD_RESIZE
_ERROR;
|
|
297 |
|
return I
MAGE_ERROR
_GD_RESIZE
_ERROR;
|
298 |
|
|
|
298 |
|
|
299 |
|
//
write tex
t on image
|
|
299 |
|
//
write tex
t on image
|
300 |
|
if
( !functi
on_exists(
'imagettf
text' ) )
|
|
300 |
|
if
( !functi
on_exists(
'imagettf
text' ) )
|
301 |
|
return I
MAGE_ERROR
_GD_TTF_NO
T_SUPPORTE
D;
|
|
301 |
|
return I
MAGE_ERROR
_GD_TTF_NO
T_SUPPORTE
D;
|
302 |
|
$c
olor = ima
gecolorall
ocate( $ds
t_im, $fon
tColorR, $
fontColorG
, $fontCol
orB );
|
|
302 |
|
$c
olor = ima
gecolorall
ocate( $ds
t_im, $fon
tColorR, $
fontColorG
, $fontCol
orB );
|
303 |
|
im
agettftext
( $dst_im,
$fontSize
, -$angle,
$textX, $
textY, $co
lor, $font
File, $tex
t );
|
|
303 |
|
im
agettftext
( $dst_im,
$fontSize
, -$angle,
$textX, $
textY, $co
lor, $font
File, $tex
t );
|
304 |
|
|
|
304 |
|
|
305 |
|
//
output he
ader
|
|
305 |
|
//
output he
ader
|
306 |
|
he
ader( "Con
tent-Type:
image/png
" );
|
|
306 |
|
he
ader( "Con
tent-Type:
image/png
" );
|
307 |
|
|
|
307 |
|
|
308 |
|
//
output im
age
|
|
308 |
|
//
output im
age
|
309 |
|
im
agepng( $d
st_im );
|
|
309 |
|
im
agepng( $d
st_im );
|
310 |
|
|
|
310 |
|
|
311 |
|
//
free memo
ry
|
|
311 |
|
//
free memo
ry
|
312 |
|
im
agedestroy
( $src_im
);
|
|
312 |
|
im
agedestroy
( $src_im
);
|
313 |
|
im
agedestroy
( $dst_im
);
|
|
313 |
|
im
agedestroy
( $dst_im
);
|
314 |
|
|
|
314 |
|
|
315 |
|
re
turn IMAGE
_ERROR_SUC
CESS;
|
|
315 |
|
re
turn IMAGE
_ERROR_SUC
CESS;
|
316 |
|
}
|
|
316 |
|
}
|
317 |
|
else
|
|
317 |
|
else
|
318 |
|
{
|
|
318 |
|
{
|
319 |
|
//
create im
age with b
ackground
|
|
319 |
|
//
create im
age with b
ackground
|
320 |
|
$w
orkFilenam
e = "{$dir
['root']}t
mp/bg{$has
h}.png";
|
|
320 |
|
$w
orkFilenam
e = "{$dir
['root']}t
mp/bg{$has
h}.png";
|
321 |
|
$c
md = "$CO
NVERT {$di
r['root']}
simg/image
s/bg{$back
groundInde
x}.png -cr
op {$sizeX
}x{$sizeY}
+{$backgro
undOffsetX
}+{$backgr
oundOffset
Y} $workFi
lename";
|
|
321 |
|
$c
md = "$CO
NVERT {$di
r['root']}
simg/image
s/bg{$back
groundInde
x}.png -cr
op {$sizeX
}x{$sizeY}
+{$backgro
undOffsetX
}+{$backgr
oundOffset
Y} $workFi
lename";
|
322 |
|
@e
xec( $cmd
);
|
|
322 |
|
@e
xec( $cmd
);
|
323 |
|
if
( !file_e
xists( $wo
rkFilename
) )
|
|
323 |
|
if
( !file_e
xists( $wo
rkFilename
) )
|
324 |
|
return I
MAGE_ERROR
_IMAGEMAGI
CK_ERROR;
|
|
324 |
|
return I
MAGE_ERROR
_IMAGEMAGI
CK_ERROR;
|
325 |
|
|
|
325 |
|
|
326 |
|
//
write tex
t on image
|
|
326 |
|
//
write tex
t on image
|
327 |
|
$w
orkFilenam
e = "{$dir
['root']}t
mp/{$hash}
.png";
|
|
327 |
|
$w
orkFilenam
e = "{$dir
['root']}t
mp/{$hash}
.png";
|
328 |
|
$c
olor = '#'
. sprintf
( '%02x',
$fontColor
R ) . spri
ntf( '%02x
', $fontCo
lorG ) . s
printf( '%
02x', $fon
tColorB );
|
|
328 |
|
$c
olor = '#'
. sprintf
( '%02x',
$fontColor
R ) . spri
ntf( '%02x
', $fontCo
lorG ) . s
printf( '%
02x', $fon
tColorB );
|
329 |
|
$t
extX += $b
ackgroundO
ffsetX;
|
|
329 |
|
$t
extX += $b
ackgroundO
ffsetX;
|
330 |
|
$t
extY += $b
ackgroundO
ffsetY;
|
|
330 |
|
$t
extY += $b
ackgroundO
ffsetY;
|
331 |
|
$c
md = "$CO
NVERT {$di
r['root']}
tmp/bg{$ha
sh}.png -f
ont $fontF
ile -fill
\"{$color}
\" -points
ize $fontS
ize -gravi
ty NorthWe
st -draw \
"translate
{$textX},
{$textY} r
otate {$an
gle} text
0,0 '{$tex
t}'\" $wor
kFilename"
;
|
|
331 |
|
$c
md = "$CO
NVERT {$di
r['root']}
tmp/bg{$ha
sh}.png -f
ont $fontF
ile -fill
\"{$color}
\" -points
ize $fontS
ize -gravi
ty NorthWe
st -draw \
"translate
{$textX},
{$textY} r
otate {$an
gle} text
0,0 '{$tex
t}'\" $wor
kFilename"
;
|
332 |
|
@e
xec( $cmd
);
|
|
332 |
|
@e
xec( $cmd
);
|
333 |
|
if
( !file_e
xists( $wo
rkFilename
) )
|
|
333 |
|
if
( !file_e
xists( $wo
rkFilename
) )
|
334 |
|
return I
MAGE_ERROR
_IMAGEMAGI
CK_ERROR;
|
|
334 |
|
return I
MAGE_ERROR
_IMAGEMAGI
CK_ERROR;
|
335 |
|
|
|
335 |
|
|
336 |
|
//
output he
ader
|
|
336 |
|
//
output he
ader
|
337 |
|
he
ader( "Con
tent-Type:
image/png
" );
|
|
337 |
|
he
ader( "Con
tent-Type:
image/png
" );
|
338 |
|
|
|
338 |
|
|
339 |
|
//
output im
age
|
|
339 |
|
//
output im
age
|
340 |
|
$f
p = fopen(
$workFile
name, 'r'
);
|
|
340 |
|
$f
p = fopen(
$workFile
name, 'r'
);
|
341 |
|
$f
size = fil
esize( $wo
rkFilename
);
|
|
341 |
|
$f
size = fil
esize( $wo
rkFilename
);
|
342 |
|
if
( !$fp )
|
|
342 |
|
if
( !$fp )
|
343 |
|
return I
MAGE_ERROR
_FILE_OPEN
_FAILED;
|
|
343 |
|
return I
MAGE_ERROR
_FILE_OPEN
_FAILED;
|
344 |
|
pr
int fread(
$fp, $fsi
ze );
|
|
344 |
|
pr
int fread(
$fp, $fsi
ze );
|
345 |
|
fc
lose( $fp
);
|
|
345 |
|
fc
lose( $fp
);
|
346 |
|
|
|
346 |
|
|
347 |
|
//
unlink te
mporary fi
les
|
|
347 |
|
//
unlink te
mporary fi
les
|
348 |
|
un
link( "{$d
ir['root']
}tmp/bg{$h
ash}.png"
);
|
|
348 |
|
un
link( "{$d
ir['root']
}tmp/bg{$h
ash}.png"
);
|
349 |
|
un
link( "{$d
ir['root']
}tmp/{$has
h}.png" );
|
|
349 |
|
un
link( "{$d
ir['root']
}tmp/{$has
h}.png" );
|
350 |
|
|
|
350 |
|
|
351 |
|
re
turn IMAGE
_ERROR_SUC
CESS;
|
|
351 |
|
re
turn IMAGE
_ERROR_SUC
CESS;
|
352 |
|
}
|
|
352 |
|
}
|
353 |
|
}
|
|
353 |
|
}
|
354 |
|
|
|
354 |
|
|
355 |
|
/**
|
|
355 |
|
/**
|
356 |
|
* Applies
watermark
to image
given in $
srcFilenam
e with spe
cified opa
city and s
aves resul
t
|
|
356 |
|
* Applies
watermark
to image
given in $
srcFilenam
e with spe
cified opa
city and s
aves resul
t
|
357 |
|
* to $dst
Filename
|
|
357 |
|
* to $dst
Filename
|
358 |
|
*
|
|
358 |
|
*
|
359 |
|
* @param
string $sr
cFilename
- source i
mage filen
ame
|
|
359 |
|
* @param
string $sr
cFilename
- source i
mage filen
ame
|
360 |
|
* @param
string $ds
tFilename
- destinat
ion image
filename
|
|
360 |
|
* @param
string $ds
tFilename
- destinat
ion image
filename
|
361 |
|
* @param
string $wt
rFilename
- watermar
k filename
|
|
361 |
|
* @param
string $wt
rFilename
- watermar
k filename
|
362 |
|
* @param
int $wtrTr
ansparency
- watermar
k transpar
ency (from
0 to 100)
|
|
362 |
|
* @param
int $wtrTr
ansparency
- watermar
k transpar
ency (from
0 to 100)
|
363 |
|
*
|
|
363 |
|
*
|
364 |
|
* @return
int
- zero on
success, n
on-zero on
fail
|
|
364 |
|
* @return
int
- zero on
success, n
on-zero on
fail
|
365 |
|
*
|
|
365 |
|
*
|
366 |
|
*
|
|
366 |
|
*
|
367 |
|
* NOTE: S
ource imag
e should b
e in GIF,
JPEG or PN
G format
|
|
367 |
|
* NOTE: S
ource imag
e should b
e in GIF,
JPEG or PN
G format
|
368 |
|
* NOTE: i
f $wtrTran
sparency =
0 then no
action wi
ll be done
with sour
ce image
|
|
368 |
|
* NOTE: i
f $wtrTran
sparency =
0 then no
action wi
ll be done
with sour
ce image
|
369 |
|
* b
ut if $wtr
Transparen
cy = 100 t
hen waterm
ark will f
ully overr
ide source
image
|
|
369 |
|
* b
ut if $wtr
Transparen
cy = 100 t
hen waterm
ark will f
ully overr
ide source
image
|
370 |
|
*/
|
|
370 |
|
*/
|
371 |
|
function a
pplyWaterm
ark( $srcF
ilename, $
dstFilenam
e, $wtrFil
ename, $wt
rTranspare
ncy )
|
|
371 |
|
function a
pplyWaterm
ark( $srcF
ilename, $
dstFilenam
e, $wtrFil
ename, $wt
rTranspare
ncy )
|
372 |
|
{
|
|
372 |
|
{
|
373 |
|
global
$use_gd;
|
|
373 |
|
global
$use_gd;
|
374 |
|
global
$COMPOSIT
E;
|
|
374 |
|
global
$COMPOSIT
E;
|
375 |
|
global
$gdInstal
led;
|
|
375 |
|
global
$gdInstal
led;
|
376 |
|
|
|
376 |
|
|
377 |
|
// inp
ut validat
ion
|
|
377 |
|
// inp
ut validat
ion
|
378 |
|
$wtrTr
ansparency
= (int) $
wtrTranspa
rency;
|
|
378 |
|
$wtrTr
ansparency
= (int) $
wtrTranspa
rency;
|
379 |
|
if ( $
wtrTranspa
rency > 10
0 )
|
|
379 |
|
if ( $
wtrTranspa
rency > 10
0 )
|
380 |
|
$w
trTranspar
ency = 100
;
|
|
380 |
|
$w
trTranspar
ency = 100
;
|
381 |
|
if ( !
file_exist
s( $srcFil
ename ) )
|
|
381 |
|
if ( !
file_exist
s( $srcFil
ename ) )
|
382 |
|
re
turn IMAGE
_ERROR_SOU
RCE_NOT_EX
ISTS;
|
|
382 |
|
re
turn IMAGE
_ERROR_SOU
RCE_NOT_EX
ISTS;
|
383 |
|
if ( !
file_exist
s( $wtrFil
ename ) )
|
|
383 |
|
if ( !
file_exist
s( $wtrFil
ename ) )
|
384 |
|
re
turn IMAGE
_ERROR_SOU
RCE_NOT_EX
ISTS;
|
|
384 |
|
re
turn IMAGE
_ERROR_SOU
RCE_NOT_EX
ISTS;
|
385 |
|
|
|
385 |
|
|
386 |
|
// if
destinatio
n and sour
ce filenam
es are equ
ivalent th
en change
mode for d
estination
|
|
386 |
|
// if
destinatio
n and sour
ce filenam
es are equ
ivalent th
en change
mode for d
estination
|
387 |
|
if ( $
srcFilenam
e == $dstF
ilename )
|
|
387 |
|
if ( $
srcFilenam
e == $dstF
ilename )
|
388 |
|
ch
mod( $dstF
ilename, 0
666 );
|
|
388 |
|
ch
mod( $dstF
ilename, 0
666 );
|
389 |
|
|
|
389 |
|
|
390 |
|
if ( $
use_gd )
|
|
390 |
|
if ( $
use_gd )
|
391 |
|
{
|
|
391 |
|
{
|
392 |
|
if
( !$gdIns
talled )
|
|
392 |
|
if
( !$gdIns
talled )
|
393 |
|
return I
MAGE_ERROR
_GD_NOT_IN
STALLED;
|
|
393 |
|
return I
MAGE_ERROR
_GD_NOT_IN
STALLED;
|
394 |
|
$g
dInfoArray
= gd_info
();
|
|
394 |
|
$g
dInfoArray
= gd_info
();
|
395 |
|
$s
ize = geti
magesize(
$srcFilena
me );
|
|
395 |
|
$s
ize = geti
magesize(
$srcFilena
me );
|
396 |
|
$w
trSize = g
etimagesiz
e( $wtrFil
ename );
|
|
396 |
|
$w
trSize = g
etimagesiz
e( $wtrFil
ename );
|
397 |
|
|
|
397 |
|
|
398 |
|
//
only GIF,
JPG and P
NG allowed
|
|
398 |
|
//
only GIF,
JPG and P
NG allowed
|
399 |
|
sw
itch ( $si
ze[2] )
|
|
399 |
|
sw
itch ( $si
ze[2] )
|
400 |
|
{
|
|
400 |
|
{
|
401 |
|
case IMA
GE_TYPE_GI
F:
|
|
401 |
|
case IMA
GE_TYPE_GI
F:
|
402 |
|
if (
!$gdInfoA
rray['GIF
Read Suppo
rt'] || !$
gdInfoArra
y['GIF Cre
ate Suppor
t'] )
|
|
402 |
|
if (
!$gdInfoA
rray['GIF
Read Suppo
rt'] || !$
gdInfoArra
y['GIF Cre
ate Suppor
t'] )
|
403 |
|
return IMA
GE_ERROR_G
D_TYPE_NOT
_SUPPORTED
;
|
|
403 |
|
return IMA
GE_ERROR_G
D_TYPE_NOT
_SUPPORTED
;
|
404 |
|
$src
_im = imag
ecreatefro
mgif( $src
Filename )
;
|
|
404 |
|
$src
_im = imag
ecreatefro
mgif( $src
Filename )
;
|
405 |
|
brea
k;
|
|
405 |
|
brea
k;
|
406 |
|
case IMA
GE_TYPE_JP
G:
|
|
406 |
|
case IMA
GE_TYPE_JP
G:
|
407 |
|
if (
!$gdInfoA
rray['JPG
Support']
)
|
|
407 |
|
if (
!$gdInfoA
rray['JPG
Support']
)
|
408 |
|
return IMA
GE_ERROR_G
D_TYPE_NOT
_SUPPORTED
;
|
|
408 |
|
return IMA
GE_ERROR_G
D_TYPE_NOT
_SUPPORTED
;
|
409 |
|
$src
_im = imag
ecreatefro
mjpeg( $sr
cFilename
);
|
|
409 |
|
$src
_im = imag
ecreatefro
mjpeg( $sr
cFilename
);
|
410 |
|
brea
k;
|
|
410 |
|
brea
k;
|
411 |
|
case IMA
GE_TYPE_PN
G:
|
|
411 |
|
case IMA
GE_TYPE_PN
G:
|
412 |
|
if (
!$gdInfoA
rray['PNG
Support']
)
|
|
412 |
|
if (
!$gdInfoA
rray['PNG
Support']
)
|
413 |
|
return IMA
GE_ERROR_G
D_TYPE_NOT
_SUPPORTED
;
|
|
413 |
|
return IMA
GE_ERROR_G
D_TYPE_NOT
_SUPPORTED
;
|
414 |
|
$src
_im = imag
ecreatefro
mpng( $src
Filename )
;
|
|
414 |
|
$src
_im = imag
ecreatefro
mpng( $src
Filename )
;
|
415 |
|
brea
k;
|
|
415 |
|
brea
k;
|
416 |
|
default:
|
|
416 |
|
default:
|
417 |
|
retu
rn IMAGE_E
RROR_WRONG
_TYPE;
|
|
417 |
|
retu
rn IMAGE_E
RROR_WRONG
_TYPE;
|
418 |
|
}
|
|
418 |
|
}
|
419 |
|
sw
itch ( $wt
rSize[2] )
|
|
419 |
|
sw
itch ( $wt
rSize[2] )
|
420 |
|
{
|
|
420 |
|
{
|
421 |
|
case IMA
GE_TYPE_GI
F:
|
|
421 |
|
case IMA
GE_TYPE_GI
F:
|
422 |
|
if (
!$gdInfoA
rray['GIF
Read Suppo
rt'] || !$
gdInfoArra
y['GIF Cre
ate Suppor
t'] )
|
|
422 |
|
if (
!$gdInfoA
rray['GIF
Read Suppo
rt'] || !$
gdInfoArra
y['GIF Cre
ate Suppor
t'] )
|
423 |
|
return IMA
GE_ERROR_G
D_TYPE_NOT
_SUPPORTED
;
|
|
423 |
|
return IMA
GE_ERROR_G
D_TYPE_NOT
_SUPPORTED
;
|
424 |
|
$wtr
_im = imag
ecreatefro
mgif( $wtr
Filename )
;
|
|
424 |
|
$wtr
_im = imag
ecreatefro
mgif( $wtr
Filename )
;
|
425 |
|
brea
k;
|
|
425 |
|
brea
k;
|
426 |
|
case IMA
GE_TYPE_JP
G:
|
|
426 |
|
case IMA
GE_TYPE_JP
G:
|
427 |
|
if (
!$gdInfoA
rray['JPG
Support']
)
|
|
427 |
|
if (
!$gdInfoA
rray['JPG
Support']
)
|
428 |
|
return IMA
GE_ERROR_G
D_TYPE_NOT
_SUPPORTED
;
|
|
428 |
|
return IMA
GE_ERROR_G
D_TYPE_NOT
_SUPPORTED
;
|
429 |
|
$wtr
_im = imag
ecreatefro
mjpeg( $wt
rFilename
);
|
|
429 |
|
$wtr
_im = imag
ecreatefro
mjpeg( $wt
rFilename
);
|
430 |
|
brea
k;
|
|
430 |
|
brea
k;
|
431 |
|
case IMA
GE_TYPE_PN
G:
|
|
431 |
|
case IMA
GE_TYPE_PN
G:
|
432 |
|
if (
!$gdInfoA
rray['PNG
Support']
)
|
|
432 |
|
if (
!$gdInfoA
rray['PNG
Support']
)
|
433 |
|
return IMA
GE_ERROR_G
D_TYPE_NOT
_SUPPORTED
;
|
|
433 |
|
return IMA
GE_ERROR_G
D_TYPE_NOT
_SUPPORTED
;
|
434 |
|
$wtr
_im = imag
ecreatefro
mpng( $wtr
Filename )
;
|
|
434 |
|
$wtr
_im = imag
ecreatefro
mpng( $wtr
Filename )
;
|
435 |
|
brea
k;
|
|
435 |
|
brea
k;
|
436 |
|
default:
|
|
436 |
|
default:
|
437 |
|
retu
rn IMAGE_E
RROR_WRONG
_TYPE;
|
|
437 |
|
retu
rn IMAGE_E
RROR_WRONG
_TYPE;
|
438 |
|
}
|
|
438 |
|
}
|
439 |
|
|
|
439 |
|
|
440 |
|
if
( !$src_i
m || !$wtr
_im )
|
|
440 |
|
if
( !$src_i
m || !$wtr
_im )
|
441 |
|
return I
MAGE_ERROR
_GD_OPEN_F
AILED;
|
|
441 |
|
return I
MAGE_ERROR
_GD_OPEN_F
AILED;
|
442 |
|
|
|
442 |
|
|
443 |
|
$w
atermarkX
= ($size[0
] - $wtrSi
ze[0]) / 2
;
|
|
443 |
|
$w
atermarkX
= ($size[0
] - $wtrSi
ze[0]) / 2
;
|
444 |
|
$w
atermarkY
= $size[1]
- $wtrSiz
e[1];
|
|
444 |
|
$w
atermarkY
= $size[1]
- $wtrSiz
e[1];
|
445 |
|
|
|
445 |
|
|
446 |
|
$m
ergeResult
= imageco
pymerge( $
src_im, $w
tr_im, $wa
termarkX,
$watermark
Y, 0, 0,
|
|
446 |
|
$m
ergeResult
= imageco
pymerge( $
src_im, $w
tr_im, $wa
termarkX,
$watermark
Y, 0, 0,
|
447 |
|
$wtrSize
[0], $wtrS
ize[1], $w
trTranspar
ency );
|
|
447 |
|
$wtrSize
[0], $wtrS
ize[1], $w
trTranspar
ency );
|
448 |
|
|
|
448 |
|
|
449 |
|
if
( !$merge
Result )
|
|
449 |
|
if
( !$merge
Result )
|
450 |
|
return I
MAGE_ERROR
_GD_MERGE_
ERROR;
|
|
450 |
|
return I
MAGE_ERROR
_GD_MERGE_
ERROR;
|
451 |
|
|
|
451 |
|
|
452 |
|
sw
itch ( $si
ze[2] )
|
|
452 |
|
sw
itch ( $si
ze[2] )
|
453 |
|
{
|
|
453 |
|
{
|
454 |
|
case IMA
GE_TYPE_GI
F:
|
|
454 |
|
case IMA
GE_TYPE_GI
F:
|
455 |
|
$wri
teResult =
imagegif(
$src_im,
$dstFilena
me );
|
|
455 |
|
$wri
teResult =
imagegif(
$src_im,
$dstFilena
me );
|
456 |
|
brea
k;
|
|
456 |
|
brea
k;
|
457 |
|
case IMA
GE_TYPE_JP
G:
|
|
457 |
|
case IMA
GE_TYPE_JP
G:
|
458 |
|
$wri
teResult =
imagejpeg
( $src_im,
$dstFilen
ame );
|
|
458 |
|
$wri
teResult =
imagejpeg
( $src_im,
$dstFilen
ame );
|
459 |
|
brea
k;
|
|
459 |
|
brea
k;
|
460 |
|
case IMA
GE_TYPE_PN
G:
|
|
460 |
|
case IMA
GE_TYPE_PN
G:
|
461 |
|
$wri
teResult =
imagepng(
$src_im,
$dstFilena
me );
|
|
461 |
|
$wri
teResult =
imagepng(
$src_im,
$dstFilena
me );
|
462 |
|
brea
k;
|
|
462 |
|
brea
k;
|
463 |
|
}
|
|
463 |
|
}
|
464 |
|
|
|
464 |
|
|
465 |
|
//
free memo
ry
|
|
465 |
|
//
free memo
ry
|
466 |
|
im
agedestroy
( $src_im
);
|
|
466 |
|
im
agedestroy
( $src_im
);
|
467 |
|
im
agedestroy
( $wtr_im
);
|
|
467 |
|
im
agedestroy
( $wtr_im
);
|
468 |
|
|
|
468 |
|
|
469 |
|
if
( $writeR
esult )
|
|
469 |
|
if
( $writeR
esult )
|
470 |
|
return I
MAGE_ERROR
_SUCCESS;
|
|
470 |
|
return I
MAGE_ERROR
_SUCCESS;
|
471 |
|
el
se
|
|
471 |
|
el
se
|
472 |
|
return I
MAGE_ERROR
_GD_WRITE_
FAILED;
|
|
472 |
|
return I
MAGE_ERROR
_GD_WRITE_
FAILED;
|
473 |
|
}
|
|
473 |
|
}
|
474 |
|
else
|
|
474 |
|
else
|
475 |
|
{
|
|
475 |
|
{
|
476 |
|
$i
mgTranspar
ency = 100
- $wtrTra
nsparency;
|
|
476 |
|
$i
mgTranspar
ency = 100
- $wtrTra
nsparency;
|
477 |
|
$c
md = "$COM
POSITE -gr
avity \"So
uth\" -dis
solve $img
Transparen
cy $wtrFil
ename -dis
solve $wtr
Transparen
cy $srcFil
ename $dst
Filename";
|
|
477 |
|
$c
md = "$COM
POSITE -gr
avity \"So
uth\" -dis
solve $img
Transparen
cy $wtrFil
ename -dis
solve $wtr
Transparen
cy $srcFil
ename $dst
Filename";
|
478 |
|
@e
xec( $cmd
);
|
|
478 |
|
@e
xec( $cmd
);
|
479 |
|
if
( file_ex
ists($dstF
ilename) )
|
|
479 |
|
if
( file_ex
ists($dstF
ilename) )
|
480 |
|
return I
MAGE_ERROR
_SUCCESS;
|
|
480 |
|
return I
MAGE_ERROR
_SUCCESS;
|
481 |
|
el
se
|
|
481 |
|
el
se
|
482 |
|
return I
MAGE_ERROR
_IMAGEMAGI
CK_ERROR;
|
|
482 |
|
return I
MAGE_ERROR
_IMAGEMAGI
CK_ERROR;
|
483 |
|
}
|
|
483 |
|
}
|
484 |
|
}
|
|
484 |
|
}
|
485 |
|
|
|
485 |
|
|
486 |
|
/**
|
|
486 |
|
/**
|
487 |
|
* Moves a
nd resize
uploaded f
ile
|
|
487 |
|
* Moves a
nd resize
uploaded f
ile
|
488 |
|
*
|
|
488 |
|
*
|
489 |
|
* @param
array $_FI
LES
- syst
em array o
f uploaded
files
|
|
489 |
|
* @param
array $_FI
LES
- syst
em array o
f uploaded
files
|
490 |
|
* @param
string $fn
ame
- name
of "file"
form
|
|
490 |
|
* @param
string $fn
ame
- name
of "file"
form
|
491 |
|
* @param
string $pa
th_and_nam
e
- path
and name
of new fil
e to creat
e
|
|
491 |
|
* @param
string $pa
th_and_nam
e
- path
and name
of new fil
e to creat
e
|
492 |
|
* @param
string $ma
xsize
- max
available
size (opti
onal)
|
|
492 |
|
* @param
string $ma
xsize
- max
available
size (opti
onal)
|
493 |
|
* @param
boolean $i
mResize
- call
imageResi
ze functio
n immediat
ely (optio
nal)
|
|
493 |
|
* @param
boolean $i
mResize
- call
imageResi
ze functio
n immediat
ely (optio
nal)
|
494 |
|
|
|
494 |
|
|
495 |
|
*
|
|
495 |
|
*
|
496 |
|
* @return
int in ca
se of erro
r and exte
ntion of n
ew file
|
|
496 |
|
* @return
int in ca
se of erro
r and exte
ntion of n
ew file
|
497 |
|
* in case
of succes
s
|
|
497 |
|
* in case
of succes
s
|
498 |
|
*
|
|
498 |
|
*
|
499 |
|
* NOTE: S
ource imag
e should b
e in GIF,
JPEG, PNG
or BMP for
mat
|
|
499 |
|
* NOTE: S
ource imag
e should b
e in GIF,
JPEG, PNG
or BMP for
mat
|
500 |
|
*/
|
|
500 |
|
*/
|
501 |
|
function m
oveUploade
dImage( $_
FILES, $fn
ame, $path
_and_name,
$maxsize=
'', $imRes
ize='true'
)
|
|
501 |
|
function m
oveUploade
dImage( $_
FILES, $fn
ame, $path
_and_name,
$maxsize=
'', $imRes
ize='true'
)
|
502 |
|
{
|
|
502 |
|
{
|
503 |
|
global
$max_phot
o_height;
|
|
503 |
|
global
$max_phot
o_height;
|
504 |
|
global
$max_phot
o_width;
|
|
504 |
|
global
$max_phot
o_width;
|
505 |
|
|
|
505 |
|
|
506 |
|
$heigh
t = $max_p
hoto_heigh
t;
|
|
506 |
|
$heigh
t = $max_p
hoto_heigh
t;
|
507 |
|
if ( !
$height )
|
|
507 |
|
if ( !
$height )
|
508 |
|
$h
eight = 40
0;
|
|
508 |
|
$h
eight = 40
0;
|
509 |
|
$width
= $max_ph
oto_width;
|
|
509 |
|
$width
= $max_ph
oto_width;
|
510 |
|
if ( !
$width )
|
|
510 |
|
if ( !
$width )
|
511 |
|
$w
idth = 400
;
|
|
511 |
|
$w
idth = 400
;
|
512 |
|
|
|
512 |
|
|
513 |
|
if ( $
maxsize &&
($_FILES[
$fname]['s
ize'] > $m
axsize ||
$_FILES[$f
name]['siz
e'] == 0)
)
|
|
513 |
|
if ( $
maxsize &&
($_FILES[
$fname]['s
ize'] > $m
axsize ||
$_FILES[$f
name]['siz
e'] == 0)
)
|
514 |
|
{
|
|
514 |
|
{
|
515 |
|
if
( file_ex
ists($_FIL
ES[$fname]
['tmp_name
']) )
|
|
515 |
|
if
( file_ex
ists($_FIL
ES[$fname]
['tmp_name
']) )
|
516 |
|
{
|
|
516 |
|
{
|
517 |
|
unlink($
_FILES[$fn
ame]['tmp_
name']);
|
|
517 |
|
unlink($
_FILES[$fn
ame]['tmp_
name']);
|
518 |
|
}
|
|
518 |
|
}
|
519 |
|
re
turn false
;
|
|
519 |
|
re
turn false
;
|
520 |
|
}
|
|
520 |
|
}
|
521 |
|
else
|
|
521 |
|
else
|
522 |
|
{
|
|
522 |
|
{
|
523 |
|
$s
can = geti
magesize($
_FILES[$fn
ame]['tmp_
name']);
|
|
523 |
|
$s
can = geti
magesize($
_FILES[$fn
ame]['tmp_
name']);
|
524 |
|
|
|
524 |
|
|
525 |
|
if
( ($scan[
'mime'] ==
'image/jp
eg' && $ex
t = '.jpg'
) ||
|
|
525 |
|
if
( ($scan[
'mime'] ==
'image/jp
eg' && $ex
t = '.jpg'
) ||
|
526 |
|
( $scan[
'mime'] ==
'image/gi
f' && $ext
= '.gif'
) ||
|
|
526 |
|
( $scan[
'mime'] ==
'image/gi
f' && $ext
= '.gif'
) ||
|
527 |
|
( $scan[
'mime'] ==
'image/pn
g' && $ext
= '.png'
) ) //dele
ted .bmp f
ormat
|
|
527 |
|
( $scan[
'mime'] ==
'image/pn
g' && $ext
= '.png'
) ) //dele
ted .bmp f
ormat
|
528 |
|
{
|
|
528 |
|
{
|
529 |
|
|
|
529 |
|
|
530 |
|
$path_an
d_name .=
$ext;
|
|
530 |
|
$path_an
d_name .=
$ext;
|
531 |
|
move_upl
oaded_file
( $_FILES[
$fname]['t
mp_name'],
$path_and
_name );
|
|
531 |
|
move_upl
oaded_file
( $_FILES[
$fname]['t
mp_name'],
$path_and
_name );
|
532 |
|
|
|
532 |
|
|
533 |
|
if ( $im
Resize )
|
|
533 |
|
if ( $im
Resize )
|
534 |
|
imag
eResize( $
path_and_n
ame, $path
_and_name,
$width, $
height );
|
|
534 |
|
imag
eResize( $
path_and_n
ame, $path
_and_name,
$width, $
height );
|
535 |
|
|
|
535 |
|
|
536 |
|
}
|
|
536 |
|
}
|
537 |
|
el
se
|
|
537 |
|
el
se
|
538 |
|
{
|
|
538 |
|
{
|
539 |
|
return I
MAGE_ERROR
_WRONG_TYP
E;
|
|
539 |
|
return I
MAGE_ERROR
_WRONG_TYP
E;
|
540 |
|
}
|
|
540 |
|
}
|
541 |
|
}
|
|
541 |
|
}
|
542 |
|
|
|
542 |
|
|
543 |
|
return
$ext;
|
|
543 |
|
return
$ext;
|
544 |
|
}
|
|
544 |
|
}
|
545 |
|
|
|
545 |
|
|
|
|
546 |
|
function R
esizeAnyPr
omo($sFrom
Path, $sTo
Path, $iCh
mod = 0644
) {
|
|
|
547 |
|
$iDefW
idth = (in
t)getParam
('promoWid
th');
|
|
|
548 |
|
if ($i
DefWidth==
0) $iDefWi
dth = 960;
|
|
|
549 |
|
|
|
|
550 |
|
imageR
esize( $sF
romPath, $
sToPath, $
iDefWidth,
$iDefWidt
h, true );
|
|
|
551 |
|
chmod(
$sToPath,
$iChmod )
;
|
|
|
552 |
|
}
|
|
|
553 |
|
|
|
|
554 |
|
function R
esizeAllPr
omos() {
|
|
|
555 |
|
global
$dir;
|
|
|
556 |
|
global
$site;
|
|
|
557 |
|
|
|
|
558 |
|
//clea
ning old
|
|
|
559 |
|
$sDest
Fold = $di
r['imagesP
romo'];
|
|
|
560 |
|
$rDir
= opendir(
$sDestFol
d );
|
|
|
561 |
|
if( $r
Dir ) {
|
|
|
562 |
|
wh
ile( $sFil
e = readdi
r( $rDir )
) {
|
|
|
563 |
|
if( $sFi
le == '.'
or $sFile
== '..' or
!is_file(
$sDestFol
d . $sFile
) )
|
|
|
564 |
|
cont
inue;
|
|
|
565 |
|
unlink($
sDestFold
. $sFile);
|
|
|
566 |
|
}
|
|
|
567 |
|
cl
osedir( $r
Dir );
|
|
|
568 |
|
}
|
|
|
569 |
|
|
|
|
570 |
|
//inse
rting new
|
|
|
571 |
|
$iImgC
nt = 1;
|
|
|
572 |
|
$sDest
Fold = $di
r['imagesP
romo'] . '
original/'
;
|
|
|
573 |
|
$rDir
= opendir(
$sDestFol
d );
|
|
|
574 |
|
if( $r
Dir ) {
|
|
|
575 |
|
wh
ile( $sFil
e = readdi
r( $rDir )
) {
|
|
|
576 |
|
if( $sFi
le == '.'
or $sFile
== '..' or
!is_file(
$sDestFol
d . $sFile
) )
|
|
|
577 |
|
cont
inue;
|
|
|
578 |
|
ResizeAn
yPromo($sD
estFold .
$sFile, $d
ir['images
Promo'] .
'big0' . $
iImgCnt .
'.jpg');
|
|
|
579 |
|
//imageR
esize( $sD
estFold .
$sFile, $d
ir['images
Promo'] .
'big0' . $
iImgCnt .
'.jpg', $i
DefWidth,
$iDefWidth
, true );
|
|
|
580 |
|
//chmod(
$dir['ima
gesPromo']
. 'big0'
. $iImgCnt
. '.jpg',
0644 );
|
|
|
581 |
|
$iImgCnt
++;
|
|
|
582 |
|
}
|
|
|
583 |
|
cl
osedir( $r
Dir );
|
|
|
584 |
|
}
|
|
|
585 |
|
|
|
|
586 |
|
}
|
546 |
|
|
|
587 |
|
|
547 |
|
?>
|
|
588 |
|
?>
|