private function get_file_mime_type_from_array($filepath) { $mime_types = array('123' => 'application/vnd.lotus-1-2-3', '3dml' => 'text/vnd.in3d.3dml', '3ds' => 'image/x-3ds', '3g2' => 'video/3gpp2', '3gp' => 'video/3gpp', '7z' => 'application/x-7z-compressed', 'aab' => 'application/x-authorware-bin', 'aac' => 'audio/x-aac', 'aam' => 'application/x-authorware-map', 'aas' => 'application/x-authorware-seg', 'abw' => 'application/x-abiword', 'ac' => 'application/pkix-attr-cert', 'acc' => 'application/vnd.americandynamics.acc', 'ace' => 'application/x-ace-compressed', 'acu' => 'application/vnd.acucobol', 'acutc' => 'application/vnd.acucorp', 'adp' => 'audio/adpcm', 'aep' => 'application/vnd.audiograph', 'afm' => 'application/x-font-type1', 'afp' => 'application/vnd.ibm.modcap', 'ahead' => 'application/vnd.ahead.space', 'ai' => 'application/postscript', 'aif' => 'audio/x-aiff', 'aifc' => 'audio/x-aiff', 'aiff' => 'audio/x-aiff', 'air' => 'application/vnd.adobe.air-application-installer-package+zip', 'ait' => 'application/vnd.dvb.ait', 'ami' => 'application/vnd.amiga.ami', 'apk' => 'application/vnd.android.package-archive', 'appcache' => 'text/cache-manifest', 'application' => 'application/x-ms-application', 'apr' => 'application/vnd.lotus-approach', 'arc' => 'application/x-freearc', 'asc' => 'application/pgp-signature', 'asf' => 'video/x-ms-asf', 'asm' => 'text/x-asm', 'aso' => 'application/vnd.accpac.simply.aso', 'asx' => 'video/x-ms-asf', 'atc' => 'application/vnd.acucorp', 'atom' => 'application/atom+xml', 'atomcat' => 'application/atomcat+xml', 'atomsvc' => 'application/atomsvc+xml', 'atx' => 'application/vnd.antix.game-component', 'au' => 'audio/basic', 'avi' => 'video/x-msvideo', 'aw' => 'application/applixware', 'azf' => 'application/vnd.airzip.filesecure.azf', 'azs' => 'application/vnd.airzip.filesecure.azs', 'azw' => 'application/vnd.amazon.ebook', 'bat' => 'application/x-msdownload', 'bcpio' => 'application/x-bcpio', 'bdf' => 'application/x-font-bdf', 'bdm' => 'application/vnd.syncml.dm+wbxml', 'bed' => 'application/vnd.realvnc.bed', 'bh2' => 'application/vnd.fujitsu.oasysprs', 'bin' => 'application/octet-stream', 'blb' => 'application/x-blorb', 'blorb' => 'application/x-blorb', 'bmi' => 'application/vnd.bmi', 'bmp' => 'image/bmp', 'book' => 'application/vnd.framemaker', 'box' => 'application/vnd.previewsystems.box', 'boz' => 'application/x-bzip2', 'bpk' => 'application/octet-stream', 'btif' => 'image/prs.btif', 'bz' => 'application/x-bzip', 'bz2' => 'application/x-bzip2', 'c' => 'text/x-c', 'c11amc' => 'application/vnd.cluetrust.cartomobile-config', 'c11amz' => 'application/vnd.cluetrust.cartomobile-config-pkg', 'c4d' => 'application/vnd.clonk.c4group', 'c4f' => 'application/vnd.clonk.c4group', 'c4g' => 'application/vnd.clonk.c4group', 'c4p' => 'application/vnd.clonk.c4group', 'c4u' => 'application/vnd.clonk.c4group', 'cab' => 'application/vnd.ms-cab-compressed', 'caf' => 'audio/x-caf', 'cap' => 'application/vnd.tcpdump.pcap', 'car' => 'application/vnd.curl.car', 'cat' => 'application/vnd.ms-pki.seccat', 'cb7' => 'application/x-cbr', 'cba' => 'application/x-cbr', 'cbr' => 'application/x-cbr', 'cbt' => 'application/x-cbr', 'cbz' => 'application/x-cbr', 'cc' => 'text/x-c', 'cct' => 'application/x-director', 'ccxml' => 'application/ccxml+xml', 'cdbcmsg' => 'application/vnd.contact.cmsg', 'cdf' => 'application/x-netcdf', 'cdkey' => 'application/vnd.mediastation.cdkey', 'cdmia' => 'application/cdmi-capability', 'cdmic' => 'application/cdmi-container', 'cdmid' => 'application/cdmi-domain', 'cdmio' => 'application/cdmi-object', 'cdmiq' => 'application/cdmi-queue', 'cdx' => 'chemical/x-cdx', 'cdxml' => 'application/vnd.chemdraw+xml', 'cdy' => 'application/vnd.cinderella', 'cer' => 'application/pkix-cert', 'cfs' => 'application/x-cfs-compressed', 'cgm' => 'image/cgm', 'chat' => 'application/x-chat', 'chm' => 'application/vnd.ms-htmlhelp', 'chrt' => 'application/vnd.kde.kchart', 'cif' => 'chemical/x-cif', 'cii' => 'application/vnd.anser-web-certificate-issue-initiation', 'cil' => 'application/vnd.ms-artgalry', 'cla' => 'application/vnd.claymore', 'class' => 'application/java-vm', 'clkk' => 'application/vnd.crick.clicker.keyboard', 'clkp' => 'application/vnd.crick.clicker.palette', 'clkt' => 'application/vnd.crick.clicker.template', 'clkw' => 'application/vnd.crick.clicker.wordbank', 'clkx' => 'application/vnd.crick.clicker', 'clp' => 'application/x-msclip', 'cmc' => 'application/vnd.cosmocaller', 'cmdf' => 'chemical/x-cmdf', 'cml' => 'chemical/x-cml', 'cmp' => 'application/vnd.yellowriver-custom-menu', 'cmx' => 'image/x-cmx', 'cod' => 'application/vnd.rim.cod', 'com' => 'application/x-msdownload', 'conf' => 'text/plain', 'cpio' => 'application/x-cpio', 'cpp' => 'text/x-c', 'cpt' => 'application/mac-compactpro', 'crd' => 'application/x-mscardfile', 'crl' => 'application/pkix-crl', 'crt' => 'application/x-x509-ca-cert', 'cryptonote' => 'application/vnd.rig.cryptonote', 'csh' => 'application/x-csh', 'csml' => 'chemical/x-csml', 'csp' => 'application/vnd.commonspace', 'css' => 'text/css', 'cst' => 'application/x-director', 'csv' => 'text/csv', 'cu' => 'application/cu-seeme', 'curl' => 'text/vnd.curl', 'cww' => 'application/prs.cww', 'cxt' => 'application/x-director', 'cxx' => 'text/x-c', 'dae' => 'model/vnd.collada+xml', 'daf' => 'application/vnd.mobius.daf', 'dart' => 'application/vnd.dart', 'dataless' => 'application/vnd.fdsn.seed', 'davmount' => 'application/davmount+xml', 'dbk' => 'application/docbook+xml', 'dcr' => 'application/x-director', 'dcurl' => 'text/vnd.curl.dcurl', 'dd2' => 'application/vnd.oma.dd2+xml', 'ddd' => 'application/vnd.fujixerox.ddd', 'deb' => 'application/x-debian-package', 'def' => 'text/plain', 'deploy' => 'application/octet-stream', 'der' => 'application/x-x509-ca-cert', 'dfac' => 'application/vnd.dreamfactory', 'dgc' => 'application/x-dgc-compressed', 'dic' => 'text/x-c', 'dif' => 'video/x-dv', 'dir' => 'application/x-director', 'dis' => 'application/vnd.mobius.dis', 'dist' => 'application/octet-stream', 'distz' => 'application/octet-stream', 'djv' => 'image/vnd.djvu', 'djvu' => 'image/vnd.djvu', 'dll' => 'application/x-msdownload', 'dmg' => 'application/x-apple-diskimage', 'dmp' => 'application/vnd.tcpdump.pcap', 'dms' => 'application/octet-stream', 'dna' => 'application/vnd.dna', 'doc' => 'application/msword', 'docm' => 'application/vnd.ms-word.document.macroenabled.12', 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'dot' => 'application/msword', 'dotm' => 'application/vnd.ms-word.template.macroenabled.12', 'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template', 'dp' => 'application/vnd.osgi.dp', 'dpg' => 'application/vnd.dpgraph', 'dra' => 'audio/vnd.dra', 'dsc' => 'text/prs.lines.tag', 'dssc' => 'application/dssc+der', 'dtb' => 'application/x-dtbook+xml', 'dtd' => 'application/xml-dtd', 'dts' => 'audio/vnd.dts', 'dtshd' => 'audio/vnd.dts.hd', 'dump' => 'application/octet-stream', 'dv' => 'video/x-dv', 'dvb' => 'video/vnd.dvb.file', 'dvi' => 'application/x-dvi', 'dwf' => 'model/vnd.dwf', 'dwg' => 'image/vnd.dwg', 'dxf' => 'image/vnd.dxf', 'dxp' => 'application/vnd.spotfire.dxp', 'dxr' => 'application/x-director', 'ecelp4800' => 'audio/vnd.nuera.ecelp4800', 'ecelp7470' => 'audio/vnd.nuera.ecelp7470', 'ecelp9600' => 'audio/vnd.nuera.ecelp9600', 'ecma' => 'application/ecmascript', 'edm' => 'application/vnd.novadigm.edm', 'edx' => 'application/vnd.novadigm.edx', 'efif' => 'application/vnd.picsel', 'ei6' => 'application/vnd.pg.osasli', 'elc' => 'application/octet-stream', 'emf' => 'application/x-msmetafile', 'eml' => 'message/rfc822', 'emma' => 'application/emma+xml', 'emz' => 'application/x-msmetafile', 'eol' => 'audio/vnd.digital-winds', 'eot' => 'application/vnd.ms-fontobject', 'eps' => 'application/postscript', 'epub' => 'application/epub+zip', 'es3' => 'application/vnd.eszigno3+xml', 'esa' => 'application/vnd.osgi.subsystem', 'esf' => 'application/vnd.epson.esf', 'et3' => 'application/vnd.eszigno3+xml', 'etx' => 'text/x-setext', 'eva' => 'application/x-eva', 'evy' => 'application/x-envoy', 'exe' => 'application/x-msdownload', 'exi' => 'application/exi', 'ext' => 'application/vnd.novadigm.ext', 'ez' => 'application/andrew-inset', 'ez2' => 'application/vnd.ezpix-album', 'ez3' => 'application/vnd.ezpix-package', 'f' => 'text/x-fortran', 'f4v' => 'video/x-f4v', 'f77' => 'text/x-fortran', 'f90' => 'text/x-fortran', 'fbs' => 'image/vnd.fastbidsheet', 'fcdt' => 'application/vnd.adobe.formscentral.fcdt', 'fcs' => 'application/vnd.isac.fcs', 'fdf' => 'application/vnd.fdf', 'fe_launch' => 'application/vnd.denovo.fcselayout-link', 'fg5' => 'application/vnd.fujitsu.oasysgp', 'fgd' => 'application/x-director', 'fh' => 'image/x-freehand', 'fh4' => 'image/x-freehand', 'fh5' => 'image/x-freehand', 'fh7' => 'image/x-freehand', 'fhc' => 'image/x-freehand', 'fig' => 'application/x-xfig', 'flac' => 'audio/x-flac', 'fli' => 'video/x-fli', 'flo' => 'application/vnd.micrografx.flo', 'flv' => 'video/x-flv', 'flw' => 'application/vnd.kde.kivio', 'flx' => 'text/vnd.fmi.flexstor', 'fly' => 'text/vnd.fly', 'fm' => 'application/vnd.framemaker', 'fnc' => 'application/vnd.frogans.fnc', 'for' => 'text/x-fortran', 'fpx' => 'image/vnd.fpx', 'frame' => 'application/vnd.framemaker', 'fsc' => 'application/vnd.fsc.weblaunch', 'fst' => 'image/vnd.fst', 'ftc' => 'application/vnd.fluxtime.clip', 'fti' => 'application/vnd.anser-web-funds-transfer-initiation', 'fvt' => 'video/vnd.fvt', 'fxp' => 'application/vnd.adobe.fxp', 'fxpl' => 'application/vnd.adobe.fxp', 'fzs' => 'application/vnd.fuzzysheet', 'g2w' => 'application/vnd.geoplan', 'g3' => 'image/g3fax', 'g3w' => 'application/vnd.geospace', 'gac' => 'application/vnd.groove-account', 'gam' => 'application/x-tads', 'gbr' => 'application/rpki-ghostbusters', 'gca' => 'application/x-gca-compressed', 'gdl' => 'model/vnd.gdl', 'geo' => 'application/vnd.dynageo', 'gex' => 'application/vnd.geometry-explorer', 'ggb' => 'application/vnd.geogebra.file', 'ggt' => 'application/vnd.geogebra.tool', 'ghf' => 'application/vnd.groove-help', 'gif' => 'image/gif', 'gim' => 'application/vnd.groove-identity-message', 'gml' => 'application/gml+xml', 'gmx' => 'application/vnd.gmx', 'gnumeric' => 'application/x-gnumeric', 'gph' => 'application/vnd.flographit', 'gpx' => 'application/gpx+xml', 'gqf' => 'application/vnd.grafeq', 'gqs' => 'application/vnd.grafeq', 'gram' => 'application/srgs', 'gramps' => 'application/x-gramps-xml', 'gre' => 'application/vnd.geometry-explorer', 'grv' => 'application/vnd.groove-injector', 'grxml' => 'application/srgs+xml', 'gsf' => 'application/x-font-ghostscript', 'gtar' => 'application/x-gtar', 'gtm' => 'application/vnd.groove-tool-message', 'gtw' => 'model/vnd.gtw', 'gv' => 'text/vnd.graphviz', 'gxf' => 'application/gxf', 'gxt' => 'application/vnd.geonext', 'h' => 'text/x-c', 'h261' => 'video/h261', 'h263' => 'video/h263', 'h264' => 'video/h264', 'hal' => 'application/vnd.hal+xml', 'hbci' => 'application/vnd.hbci', 'hdf' => 'application/x-hdf', 'hh' => 'text/x-c', 'hlp' => 'application/winhlp', 'hpgl' => 'application/vnd.hp-hpgl', 'hpid' => 'application/vnd.hp-hpid', 'hps' => 'application/vnd.hp-hps', 'hqx' => 'application/mac-binhex40', 'htke' => 'application/vnd.kenameaapp', 'htm' => 'text/html', 'html' => 'text/html', 'hvd' => 'application/vnd.yamaha.hv-dic', 'hvp' => 'application/vnd.yamaha.hv-voice', 'hvs' => 'application/vnd.yamaha.hv-script', 'i2g' => 'application/vnd.intergeo', 'icc' => 'application/vnd.iccprofile', 'ice' => 'x-conference/x-cooltalk', 'icm' => 'application/vnd.iccprofile', 'ico' => 'image/x-icon', 'ics' => 'text/calendar', 'ief' => 'image/ief', 'ifb' => 'text/calendar', 'ifm' => 'application/vnd.shana.informed.formdata', 'iges' => 'model/iges', 'igl' => 'application/vnd.igloader', 'igm' => 'application/vnd.insors.igm', 'igs' => 'model/iges', 'igx' => 'application/vnd.micrografx.igx', 'iif' => 'application/vnd.shana.informed.interchange', 'imp' => 'application/vnd.accpac.simply.imp', 'ims' => 'application/vnd.ms-ims', 'in' => 'text/plain', 'ink' => 'application/inkml+xml', 'inkml' => 'application/inkml+xml', 'install' => 'application/x-install-instructions', 'iota' => 'application/vnd.astraea-software.iota', 'ipfix' => 'application/ipfix', 'ipk' => 'application/vnd.shana.informed.package', 'irm' => 'application/vnd.ibm.rights-management', 'irp' => 'application/vnd.irepository.package+xml', 'iso' => 'application/x-iso9660-image', 'itp' => 'application/vnd.shana.informed.formtemplate', 'ivp' => 'application/vnd.immervision-ivp', 'ivu' => 'application/vnd.immervision-ivu', 'jad' => 'text/vnd.sun.j2me.app-descriptor', 'jam' => 'application/vnd.jam', 'jar' => 'application/java-archive', 'java' => 'text/x-java-source', 'jisp' => 'application/vnd.jisp', 'jlt' => 'application/vnd.hp-jlyt', 'jnlp' => 'application/x-java-jnlp-file', 'joda' => 'application/vnd.joost.joda-archive', 'jp2' => 'image/jp2', 'jpe' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'jpg' => 'image/jpeg', 'jpgm' => 'video/jpm', 'jpgv' => 'video/jpeg', 'jpm' => 'video/jpm', 'js' => 'application/javascript', 'json' => 'application/json', 'jsonml' => 'application/jsonml+json', 'kar' => 'audio/midi', 'karbon' => 'application/vnd.kde.karbon', 'kfo' => 'application/vnd.kde.kformula', 'kia' => 'application/vnd.kidspiration', 'kml' => 'application/vnd.google-earth.kml+xml', 'kmz' => 'application/vnd.google-earth.kmz', 'kne' => 'application/vnd.kinar', 'knp' => 'application/vnd.kinar', 'kon' => 'application/vnd.kde.kontour', 'kpr' => 'application/vnd.kde.kpresenter', 'kpt' => 'application/vnd.kde.kpresenter', 'kpxx' => 'application/vnd.ds-keypoint', 'ksp' => 'application/vnd.kde.kspread', 'ktr' => 'application/vnd.kahootz', 'ktx' => 'image/ktx', 'ktz' => 'application/vnd.kahootz', 'kwd' => 'application/vnd.kde.kword', 'kwt' => 'application/vnd.kde.kword', 'lasxml' => 'application/vnd.las.las+xml', 'latex' => 'application/x-latex', 'lbd' => 'application/vnd.llamagraphics.life-balance.desktop', 'lbe' => 'application/vnd.llamagraphics.life-balance.exchange+xml', 'les' => 'application/vnd.hhe.lesson-player', 'lha' => 'application/x-lzh-compressed', 'link66' => 'application/vnd.route66.link66+xml', 'list' => 'text/plain', 'list3820' => 'application/vnd.ibm.modcap', 'listafp' => 'application/vnd.ibm.modcap', 'lnk' => 'application/x-ms-shortcut', 'log' => 'text/plain', 'lostxml' => 'application/lost+xml', 'lrf' => 'application/octet-stream', 'lrm' => 'application/vnd.ms-lrm', 'ltf' => 'application/vnd.frogans.ltf', 'lvp' => 'audio/vnd.lucent.voice', 'lwp' => 'application/vnd.lotus-wordpro', 'lzh' => 'application/x-lzh-compressed', 'm13' => 'application/x-msmediaview', 'm14' => 'application/x-msmediaview', 'm1v' => 'video/mpeg', 'm21' => 'application/mp21', 'm2a' => 'audio/mpeg', 'm2v' => 'video/mpeg', 'm3a' => 'audio/mpeg', 'm3u' => 'audio/x-mpegurl', 'm3u8' => 'application/x-mpegurl', 'm4a' => 'audio/mp4a-latm', 'm4p' => 'audio/mp4a-latm', 'm4u' => 'video/vnd.mpegurl', 'm4v' => 'video/x-m4v', 'ma' => 'application/mathematica', 'mac' => 'image/x-macpaint', 'mads' => 'application/mads+xml', 'mag' => 'application/vnd.ecowin.chart', 'maker' => 'application/vnd.framemaker', 'man' => 'text/troff', 'manifest' => 'text/cache-manifest', 'mar' => 'application/octet-stream', 'mathml' => 'application/mathml+xml', 'mb' => 'application/mathematica', 'mbk' => 'application/vnd.mobius.mbk', 'mbox' => 'application/mbox', 'mc1' => 'application/vnd.medcalcdata', 'mcd' => 'application/vnd.mcd', 'mcurl' => 'text/vnd.curl.mcurl', 'mdb' => 'application/x-msaccess', 'mdi' => 'image/vnd.ms-modi', 'me' => 'text/troff', 'mesh' => 'model/mesh', 'meta4' => 'application/metalink4+xml', 'metalink' => 'application/metalink+xml', 'mets' => 'application/mets+xml', 'mfm' => 'application/vnd.mfmp', 'mft' => 'application/rpki-manifest', 'mgp' => 'application/vnd.osgeo.mapguide.package', 'mgz' => 'application/vnd.proteus.magazine', 'mid' => 'audio/midi', 'midi' => 'audio/midi', 'mie' => 'application/x-mie', 'mif' => 'application/vnd.mif', 'mime' => 'message/rfc822', 'mj2' => 'video/mj2', 'mjp2' => 'video/mj2', 'mk3d' => 'video/x-matroska', 'mka' => 'audio/x-matroska', 'mks' => 'video/x-matroska', 'mkv' => 'video/x-matroska', 'mlp' => 'application/vnd.dolby.mlp', 'mmd' => 'application/vnd.chipnuts.karaoke-mmd', 'mmf' => 'application/vnd.smaf', 'mmr' => 'image/vnd.fujixerox.edmics-mmr', 'mng' => 'video/x-mng', 'mny' => 'application/x-msmoney', 'mobi' => 'application/x-mobipocket-ebook', 'mobipocket-ebook' => 'application/octet-stream', 'mods' => 'application/mods+xml', 'mov' => 'video/quicktime', 'movie' => 'video/x-sgi-movie', 'mp2' => 'audio/mpeg', 'mp21' => 'application/mp21', 'mp2a' => 'audio/mpeg', 'mp3' => 'audio/mpeg', 'mp4' => 'video/mp4', 'mp4a' => 'audio/mp4', 'mp4s' => 'application/mp4', 'mp4v' => 'video/mp4', 'mpc' => 'application/vnd.mophun.certificate', 'mpe' => 'video/mpeg', 'mpeg' => 'video/mpeg', 'mpg' => 'video/mpeg', 'mpg4' => 'video/mp4', 'mpga' => 'audio/mpeg', 'mpkg' => 'application/vnd.apple.installer+xml', 'mpm' => 'application/vnd.blueice.multipass', 'mpn' => 'application/vnd.mophun.application', 'mpp' => 'application/vnd.ms-project', 'mpt' => 'application/vnd.ms-project', 'mpy' => 'application/vnd.ibm.minipay', 'mqy' => 'application/vnd.mobius.mqy', 'mrc' => 'application/marc', 'mrcx' => 'application/marcxml+xml', 'ms' => 'text/troff', 'mscml' => 'application/mediaservercontrol+xml', 'mseed' => 'application/vnd.fdsn.mseed', 'mseq' => 'application/vnd.mseq', 'msf' => 'application/vnd.epson.msf', 'msh' => 'model/mesh', 'msi' => 'application/x-msdownload', 'msl' => 'application/vnd.mobius.msl', 'msty' => 'application/vnd.muvee.style', 'mts' => 'model/vnd.mts', 'mus' => 'application/vnd.musician', 'musicxml' => 'application/vnd.recordare.musicxml+xml', 'mvb' => 'application/x-msmediaview', 'mwf' => 'application/vnd.mfer', 'mxf' => 'application/mxf', 'mxl' => 'application/vnd.recordare.musicxml', 'mxml' => 'application/xv+xml', 'mxs' => 'application/vnd.triscape.mxs', 'mxu' => 'video/vnd.mpegurl', 'n-gage' => 'application/vnd.nokia.n-gage.symbian.install', 'n3' => 'text/n3', 'nb' => 'application/mathematica', 'nbp' => 'application/vnd.wolfram.player', 'nc' => 'application/x-netcdf', 'ncx' => 'application/x-dtbncx+xml', 'nfo' => 'text/x-nfo', 'ngdat' => 'application/vnd.nokia.n-gage.data', 'nitf' => 'application/vnd.nitf', 'nlu' => 'application/vnd.neurolanguage.nlu', 'nml' => 'application/vnd.enliven', 'nnd' => 'application/vnd.noblenet-directory', 'nns' => 'application/vnd.noblenet-sealer', 'nnw' => 'application/vnd.noblenet-web', 'npx' => 'image/vnd.net-fpx', 'nsc' => 'application/x-conference', 'nsf' => 'application/vnd.lotus-notes', 'ntf' => 'application/vnd.nitf', 'nzb' => 'application/x-nzb', 'oa2' => 'application/vnd.fujitsu.oasys2', 'oa3' => 'application/vnd.fujitsu.oasys3', 'oas' => 'application/vnd.fujitsu.oasys', 'obd' => 'application/x-msbinder', 'obj' => 'application/x-tgif', 'oda' => 'application/oda', 'odb' => 'application/vnd.oasis.opendocument.database', 'odc' => 'application/vnd.oasis.opendocument.chart', 'odf' => 'application/vnd.oasis.opendocument.formula', 'odft' => 'application/vnd.oasis.opendocument.formula-template', 'odg' => 'application/vnd.oasis.opendocument.graphics', 'odi' => 'application/vnd.oasis.opendocument.image', 'odm' => 'application/vnd.oasis.opendocument.text-master', 'odp' => 'application/vnd.oasis.opendocument.presentation', 'ods' => 'application/vnd.oasis.opendocument.spreadsheet', 'odt' => 'application/vnd.oasis.opendocument.text', 'oga' => 'audio/ogg', 'ogg' => 'audio/ogg', 'ogv' => 'video/ogg', 'ogx' => 'application/ogg', 'omdoc' => 'application/omdoc+xml', 'onepkg' => 'application/onenote', 'onetmp' => 'application/onenote', 'onetoc' => 'application/onenote', 'onetoc2' => 'application/onenote', 'opf' => 'application/oebps-package+xml', 'opml' => 'text/x-opml', 'oprc' => 'application/vnd.palm', 'org' => 'application/vnd.lotus-organizer', 'osf' => 'application/vnd.yamaha.openscoreformat', 'osfpvg' => 'application/vnd.yamaha.openscoreformat.osfpvg+xml', 'otc' => 'application/vnd.oasis.opendocument.chart-template', 'otf' => 'application/x-font-otf', 'otg' => 'application/vnd.oasis.opendocument.graphics-template', 'oth' => 'application/vnd.oasis.opendocument.text-web', 'oti' => 'application/vnd.oasis.opendocument.image-template', 'otp' => 'application/vnd.oasis.opendocument.presentation-template', 'ots' => 'application/vnd.oasis.opendocument.spreadsheet-template', 'ott' => 'application/vnd.oasis.opendocument.text-template', 'oxps' => 'application/oxps', 'oxt' => 'application/vnd.openofficeorg.extension', 'p' => 'text/x-pascal', 'p10' => 'application/pkcs10', 'p12' => 'application/x-pkcs12', 'p7b' => 'application/x-pkcs7-certificates', 'p7c' => 'application/pkcs7-mime', 'p7m' => 'application/pkcs7-mime', 'p7r' => 'application/x-pkcs7-certreqresp', 'p7s' => 'application/pkcs7-signature', 'p8' => 'application/pkcs8', 'pas' => 'text/x-pascal', 'paw' => 'application/vnd.pawaafile', 'pbd' => 'application/vnd.powerbuilder6', 'pbm' => 'image/x-portable-bitmap', 'pcap' => 'application/vnd.tcpdump.pcap', 'pcf' => 'application/x-font-pcf', 'pcl' => 'application/vnd.hp-pcl', 'pclxl' => 'application/vnd.hp-pclxl', 'pct' => 'image/x-pict', 'pcurl' => 'application/vnd.curl.pcurl', 'pcx' => 'image/x-pcx', 'pdb' => 'application/vnd.palm', 'pdf' => 'application/pdf', 'pfa' => 'application/x-font-type1', 'pfb' => 'application/x-font-type1', 'pfm' => 'application/x-font-type1', 'pfr' => 'application/font-tdpfr', 'pfx' => 'application/x-pkcs12', 'pgm' => 'image/x-portable-graymap', 'pgn' => 'application/x-chess-pgn', 'pgp' => 'application/pgp-encrypted', 'pic' => 'image/x-pict', 'pict' => 'image/pict', 'pkg' => 'application/octet-stream', 'pki' => 'application/pkixcmp', 'pkipath' => 'application/pkix-pkipath', 'plb' => 'application/vnd.3gpp.pic-bw-large', 'plc' => 'application/vnd.mobius.plc', 'plf' => 'application/vnd.pocketlearn', 'pls' => 'application/pls+xml', 'pml' => 'application/vnd.ctc-posml', 'png' => 'image/png', 'pnm' => 'image/x-portable-anymap', 'pnt' => 'image/x-macpaint', 'pntg' => 'image/x-macpaint', 'portpkg' => 'application/vnd.macports.portpkg', 'pot' => 'application/vnd.ms-powerpoint', 'potm' => 'application/vnd.ms-powerpoint.template.macroenabled.12', 'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template', 'ppam' => 'application/vnd.ms-powerpoint.addin.macroenabled.12', 'ppd' => 'application/vnd.cups-ppd', 'ppm' => 'image/x-portable-pixmap', 'pps' => 'application/vnd.ms-powerpoint', 'ppsm' => 'application/vnd.ms-powerpoint.slideshow.macroenabled.12', 'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow', 'ppt' => 'application/vnd.ms-powerpoint', 'pptm' => 'application/vnd.ms-powerpoint.presentation.macroenabled.12', 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', 'pqa' => 'application/vnd.palm', 'prc' => 'application/x-mobipocket-ebook', 'pre' => 'application/vnd.lotus-freelance', 'prf' => 'application/pics-rules', 'ps' => 'application/postscript', 'psb' => 'application/vnd.3gpp.pic-bw-small', 'psd' => 'image/vnd.adobe.photoshop', 'psf' => 'application/x-font-linux-psf', 'pskcxml' => 'application/pskc+xml', 'ptid' => 'application/vnd.pvi.ptid1', 'pub' => 'application/x-mspublisher', 'pvb' => 'application/vnd.3gpp.pic-bw-var', 'pwn' => 'application/vnd.3m.post-it-notes', 'pya' => 'audio/vnd.ms-playready.media.pya', 'pyv' => 'video/vnd.ms-playready.media.pyv', 'qam' => 'application/vnd.epson.quickanime', 'qbo' => 'application/vnd.intu.qbo', 'qfx' => 'application/vnd.intu.qfx', 'qps' => 'application/vnd.publishare-delta-tree', 'qt' => 'video/quicktime', 'qti' => 'image/x-quicktime', 'qtif' => 'image/x-quicktime', 'qwd' => 'application/vnd.quark.quarkxpress', 'qwt' => 'application/vnd.quark.quarkxpress', 'qxb' => 'application/vnd.quark.quarkxpress', 'qxd' => 'application/vnd.quark.quarkxpress', 'qxl' => 'application/vnd.quark.quarkxpress', 'qxt' => 'application/vnd.quark.quarkxpress', 'ra' => 'audio/x-pn-realaudio', 'ram' => 'audio/x-pn-realaudio', 'rar' => 'application/x-rar-compressed', 'ras' => 'image/x-cmu-raster', 'rcprofile' => 'application/vnd.ipunplugged.rcprofile', 'rdf' => 'application/rdf+xml', 'rdz' => 'application/vnd.data-vision.rdz', 'rep' => 'application/vnd.businessobjects', 'res' => 'application/x-dtbresource+xml', 'rgb' => 'image/x-rgb', 'rif' => 'application/reginfo+xml', 'rip' => 'audio/vnd.rip', 'ris' => 'application/x-research-info-systems', 'rl' => 'application/resource-lists+xml', 'rlc' => 'image/vnd.fujixerox.edmics-rlc', 'rld' => 'application/resource-lists-diff+xml', 'rm' => 'application/vnd.rn-realmedia', 'rmi' => 'audio/midi', 'rmp' => 'audio/x-pn-realaudio-plugin', 'rms' => 'application/vnd.jcp.javame.midlet-rms', 'rmvb' => 'application/vnd.rn-realmedia-vbr', 'rnc' => 'application/relax-ng-compact-syntax', 'roa' => 'application/rpki-roa', 'roff' => 'text/troff', 'rp9' => 'application/vnd.cloanto.rp9', 'rpss' => 'application/vnd.nokia.radio-presets', 'rpst' => 'application/vnd.nokia.radio-preset', 'rq' => 'application/sparql-query', 'rs' => 'application/rls-services+xml', 'rsd' => 'application/rsd+xml', 'rss' => 'application/rss+xml', 'rtf' => 'application/rtf', 'rtx' => 'text/richtext', 's' => 'text/x-asm', 's3m' => 'audio/s3m', 'saf' => 'application/vnd.yamaha.smaf-audio', 'sbml' => 'application/sbml+xml', 'sc' => 'application/vnd.ibm.secure-container', 'scd' => 'application/x-msschedule', 'scm' => 'application/vnd.lotus-screencam', 'scq' => 'application/scvp-cv-request', 'scs' => 'application/scvp-cv-response', 'scurl' => 'text/vnd.curl.scurl', 'sda' => 'application/vnd.stardivision.draw', 'sdc' => 'application/vnd.stardivision.calc', 'sdd' => 'application/vnd.stardivision.impress', 'sdkd' => 'application/vnd.solent.sdkm+xml', 'sdkm' => 'application/vnd.solent.sdkm+xml', 'sdp' => 'application/sdp', 'sdw' => 'application/vnd.stardivision.writer', 'see' => 'application/vnd.seemail', 'seed' => 'application/vnd.fdsn.seed', 'sema' => 'application/vnd.sema', 'semd' => 'application/vnd.semd', 'semf' => 'application/vnd.semf', 'ser' => 'application/java-serialized-object', 'setpay' => 'application/set-payment-initiation', 'setreg' => 'application/set-registration-initiation', 'sfd-hdstx' => 'application/vnd.hydrostatix.sof-data', 'sfs' => 'application/vnd.spotfire.sfs', 'sfv' => 'text/x-sfv', 'sgi' => 'image/sgi', 'sgl' => 'application/vnd.stardivision.writer-global', 'sgm' => 'text/sgml', 'sgml' => 'text/sgml', 'sh' => 'application/x-sh', 'shar' => 'application/x-shar', 'shf' => 'application/shf+xml', 'sid' => 'image/x-mrsid-image', 'sig' => 'application/pgp-signature', 'sil' => 'audio/silk', 'silo' => 'model/mesh', 'sis' => 'application/vnd.symbian.install', 'sisx' => 'application/vnd.symbian.install', 'sit' => 'application/x-stuffit', 'sitx' => 'application/x-stuffitx', 'skd' => 'application/vnd.koan', 'skm' => 'application/vnd.koan', 'skp' => 'application/vnd.koan', 'skt' => 'application/vnd.koan', 'sldm' => 'application/vnd.ms-powerpoint.slide.macroenabled.12', 'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide', 'slt' => 'application/vnd.epson.salt', 'sm' => 'application/vnd.stepmania.stepchart', 'smf' => 'application/vnd.stardivision.math', 'smi' => 'application/smil+xml', 'smil' => 'application/smil+xml', 'smv' => 'video/x-smv', 'smzip' => 'application/vnd.stepmania.package', 'snd' => 'audio/basic', 'snf' => 'application/x-font-snf', 'so' => 'application/octet-stream', 'spc' => 'application/x-pkcs7-certificates', 'spf' => 'application/vnd.yamaha.smaf-phrase', 'spl' => 'application/x-futuresplash', 'spot' => 'text/vnd.in3d.spot', 'spp' => 'application/scvp-vp-response', 'spq' => 'application/scvp-vp-request', 'spx' => 'audio/ogg', 'sql' => 'application/x-sql', 'src' => 'application/x-wais-source', 'srt' => 'application/x-subrip', 'sru' => 'application/sru+xml', 'srx' => 'application/sparql-results+xml', 'ssdl' => 'application/ssdl+xml', 'sse' => 'application/vnd.kodak-descriptor', 'ssf' => 'application/vnd.epson.ssf', 'ssml' => 'application/ssml+xml', 'st' => 'application/vnd.sailingtracker.track', 'stc' => 'application/vnd.sun.xml.calc.template', 'std' => 'application/vnd.sun.xml.draw.template', 'stf' => 'application/vnd.wt.stf', 'sti' => 'application/vnd.sun.xml.impress.template', 'stk' => 'application/hyperstudio', 'stl' => 'application/vnd.ms-pki.stl', 'str' => 'application/vnd.pg.format', 'stw' => 'application/vnd.sun.xml.writer.template', 'sub' => 'text/vnd.dvb.subtitle', 'sus' => 'application/vnd.sus-calendar', 'susp' => 'application/vnd.sus-calendar', 'sv4cpio' => 'application/x-sv4cpio', 'sv4crc' => 'application/x-sv4crc', 'svc' => 'application/vnd.dvb.service', 'svd' => 'application/vnd.svd', 'svg' => 'image/svg+xml', 'svgz' => 'image/svg+xml', 'swa' => 'application/x-director', 'swf' => 'application/x-shockwave-flash', 'swi' => 'application/vnd.aristanetworks.swi', 'sxc' => 'application/vnd.sun.xml.calc', 'sxd' => 'application/vnd.sun.xml.draw', 'sxg' => 'application/vnd.sun.xml.writer.global', 'sxi' => 'application/vnd.sun.xml.impress', 'sxm' => 'application/vnd.sun.xml.math', 'sxw' => 'application/vnd.sun.xml.writer', 't' => 'text/troff', 't3' => 'application/x-t3vm-image', 'taglet' => 'application/vnd.mynfc', 'tao' => 'application/vnd.tao.intent-module-archive', 'tar' => 'application/x-tar', 'tcap' => 'application/vnd.3gpp2.tcap', 'tcl' => 'application/x-tcl', 'teacher' => 'application/vnd.smart.teacher', 'tei' => 'application/tei+xml', 'teicorpus' => 'application/tei+xml', 'tex' => 'application/x-tex', 'texi' => 'application/x-texinfo', 'texinfo' => 'application/x-texinfo', 'text' => 'text/plain', 'tfi' => 'application/thraud+xml', 'tfm' => 'application/x-tex-tfm', 'tga' => 'image/x-tga', 'thmx' => 'application/vnd.ms-officetheme', 'tif' => 'image/tiff', 'tiff' => 'image/tiff', 'tmo' => 'application/vnd.tmobile-livetv', 'torrent' => 'application/x-bittorrent', 'tpl' => 'application/vnd.groove-tool-template', 'tpt' => 'application/vnd.trid.tpt', 'tr' => 'text/troff', 'tra' => 'application/vnd.trueapp', 'trm' => 'application/x-msterminal', 'ts' => 'video/mp2t', 'tsd' => 'application/timestamped-data', 'tsv' => 'text/tab-separated-values', 'ttc' => 'application/x-font-ttf', 'ttf' => 'application/x-font-ttf', 'ttl' => 'text/turtle', 'twd' => 'application/vnd.simtech-mindmapper', 'twds' => 'application/vnd.simtech-mindmapper', 'txd' => 'application/vnd.genomatix.tuxedo', 'txf' => 'application/vnd.mobius.txf', 'txt' => 'text/plain', 'u32' => 'application/x-authorware-bin', 'udeb' => 'application/x-debian-package', 'ufd' => 'application/vnd.ufdl', 'ufdl' => 'application/vnd.ufdl', 'ulx' => 'application/x-glulx', 'umj' => 'application/vnd.umajin', 'unityweb' => 'application/vnd.unity', 'uoml' => 'application/vnd.uoml+xml', 'uri' => 'text/uri-list', 'uris' => 'text/uri-list', 'urls' => 'text/uri-list', 'ustar' => 'application/x-ustar', 'utz' => 'application/vnd.uiq.theme', 'uu' => 'text/x-uuencode', 'uva' => 'audio/vnd.dece.audio', 'uvd' => 'application/vnd.dece.data', 'uvf' => 'application/vnd.dece.data', 'uvg' => 'image/vnd.dece.graphic', 'uvh' => 'video/vnd.dece.hd', 'uvi' => 'image/vnd.dece.graphic', 'uvm' => 'video/vnd.dece.mobile', 'uvp' => 'video/vnd.dece.pd', 'uvs' => 'video/vnd.dece.sd', 'uvt' => 'application/vnd.dece.ttml+xml', 'uvu' => 'video/vnd.uvvu.mp4', 'uvv' => 'video/vnd.dece.video', 'uvva' => 'audio/vnd.dece.audio', 'uvvd' => 'application/vnd.dece.data', 'uvvf' => 'application/vnd.dece.data', 'uvvg' => 'image/vnd.dece.graphic', 'uvvh' => 'video/vnd.dece.hd', 'uvvi' => 'image/vnd.dece.graphic', 'uvvm' => 'video/vnd.dece.mobile', 'uvvp' => 'video/vnd.dece.pd', 'uvvs' => 'video/vnd.dece.sd', 'uvvt' => 'application/vnd.dece.ttml+xml', 'uvvu' => 'video/vnd.uvvu.mp4', 'uvvv' => 'video/vnd.dece.video', 'uvvx' => 'application/vnd.dece.unspecified', 'uvvz' => 'application/vnd.dece.zip', 'uvx' => 'application/vnd.dece.unspecified', 'uvz' => 'application/vnd.dece.zip', 'vcard' => 'text/vcard', 'vcd' => 'application/x-cdlink', 'vcf' => 'text/x-vcard', 'vcg' => 'application/vnd.groove-vcard', 'vcs' => 'text/x-vcalendar', 'vcx' => 'application/vnd.vcx', 'vis' => 'application/vnd.visionary', 'viv' => 'video/vnd.vivo', 'vob' => 'video/x-ms-vob', 'vor' => 'application/vnd.stardivision.writer', 'vox' => 'application/x-authorware-bin', 'vrml' => 'model/vrml', 'vsd' => 'application/vnd.visio', 'vsf' => 'application/vnd.vsf', 'vss' => 'application/vnd.visio', 'vst' => 'application/vnd.visio', 'vsw' => 'application/vnd.visio', 'vtu' => 'model/vnd.vtu', 'vxml' => 'application/voicexml+xml', 'w3d' => 'application/x-director', 'wad' => 'application/x-doom', 'wav' => 'audio/x-wav', 'wax' => 'audio/x-ms-wax', 'wbmp' => 'image/vnd.wap.wbmp', 'wbs' => 'application/vnd.criticaltools.wbs+xml', 'wbxml' => 'application/vnd.wap.wbxml', 'wcm' => 'application/vnd.ms-works', 'wdb' => 'application/vnd.ms-works', 'wdp' => 'image/vnd.ms-photo', 'weba' => 'audio/webm', 'webm' => 'video/webm', 'webp' => 'image/webp', 'wg' => 'application/vnd.pmi.widget', 'wgt' => 'application/widget', 'wks' => 'application/vnd.ms-works', 'wm' => 'video/x-ms-wm', 'wma' => 'audio/x-ms-wma', 'wmd' => 'application/x-ms-wmd', 'wmf' => 'application/x-msmetafile', 'wml' => 'text/vnd.wap.wml', 'wmlc' => 'application/vnd.wap.wmlc', 'wmls' => 'text/vnd.wap.wmlscript', 'wmlsc' => 'application/vnd.wap.wmlscriptc', 'wmv' => 'video/x-ms-wmv', 'wmx' => 'video/x-ms-wmx', 'wmz' => 'application/x-msmetafile', 'woff' => 'application/x-font-woff', 'wpd' => 'application/vnd.wordperfect', 'wpl' => 'application/vnd.ms-wpl', 'wps' => 'application/vnd.ms-works', 'wqd' => 'application/vnd.wqd', 'wri' => 'application/x-mswrite', 'wrl' => 'model/vrml', 'wsdl' => 'application/wsdl+xml', 'wspolicy' => 'application/wspolicy+xml', 'wtb' => 'application/vnd.webturbo', 'wvx' => 'video/x-ms-wvx', 'x32' => 'application/x-authorware-bin', 'x3d' => 'model/x3d+xml', 'x3db' => 'model/x3d+binary', 'x3dbz' => 'model/x3d+binary', 'x3dv' => 'model/x3d+vrml', 'x3dvz' => 'model/x3d+vrml', 'x3dz' => 'model/x3d+xml', 'xaml' => 'application/xaml+xml', 'xap' => 'application/x-silverlight-app', 'xar' => 'application/vnd.xara', 'xbap' => 'application/x-ms-xbap', 'xbd' => 'application/vnd.fujixerox.docuworks.binder', 'xbm' => 'image/x-xbitmap', 'xdf' => 'application/xcap-diff+xml', 'xdm' => 'application/vnd.syncml.dm+xml', 'xdp' => 'application/vnd.adobe.xdp+xml', 'xdssc' => 'application/dssc+xml', 'xdw' => 'application/vnd.fujixerox.docuworks', 'xenc' => 'application/xenc+xml', 'xer' => 'application/patch-ops-error+xml', 'xfdf' => 'application/vnd.adobe.xfdf', 'xfdl' => 'application/vnd.xfdl', 'xht' => 'application/xhtml+xml', 'xhtml' => 'application/xhtml+xml', 'xhvml' => 'application/xv+xml', 'xif' => 'image/vnd.xiff', 'xla' => 'application/vnd.ms-excel', 'xlam' => 'application/vnd.ms-excel.addin.macroenabled.12', 'xlc' => 'application/vnd.ms-excel', 'xlf' => 'application/x-xliff+xml', 'xlm' => 'application/vnd.ms-excel', 'xls' => 'application/vnd.ms-excel', 'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroenabled.12', 'xlsm' => 'application/vnd.ms-excel.sheet.macroenabled.12', 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'xlt' => 'application/vnd.ms-excel', 'xltm' => 'application/vnd.ms-excel.template.macroenabled.12', 'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template', 'xlw' => 'application/vnd.ms-excel', 'xm' => 'audio/xm', 'xml' => 'application/xml', 'xo' => 'application/vnd.olpc-sugar', 'xop' => 'application/xop+xml', 'xpi' => 'application/x-xpinstall', 'xpl' => 'application/xproc+xml', 'xpm' => 'image/x-xpixmap', 'xpr' => 'application/vnd.is-xpr', 'xps' => 'application/vnd.ms-xpsdocument', 'xpw' => 'application/vnd.intercon.formnet', 'xpx' => 'application/vnd.intercon.formnet', 'xsl' => 'application/xml', 'xslt' => 'application/xslt+xml', 'xsm' => 'application/vnd.syncml+xml', 'xspf' => 'application/xspf+xml', 'xul' => 'application/vnd.mozilla.xul+xml', 'xvm' => 'application/xv+xml', 'xvml' => 'application/xv+xml', 'xwd' => 'image/x-xwindowdump', 'xyz' => 'chemical/x-xyz', 'xz' => 'application/x-xz', 'yang' => 'application/yang', 'yin' => 'application/yin+xml', 'z1' => 'application/x-zmachine', 'z2' => 'application/x-zmachine', 'z3' => 'application/x-zmachine', 'z4' => 'application/x-zmachine', 'z5' => 'application/x-zmachine', 'z6' => 'application/x-zmachine', 'z7' => 'application/x-zmachine', 'z8' => 'application/x-zmachine', 'zaz' => 'application/vnd.zzazz.deck+xml', 'zip' => 'application/zip', 'zir' => 'application/vnd.zul', 'zirz' => 'application/vnd.zul', 'zmm' => 'application/vnd.handheld-entertainment+xml'); $extension = strtolower(awpcp_get_file_extension($filepath)); $mime_type = awpcp_array_data($extension, 'application/octet-stream', $mime_types); return $mime_type; }
private function consolidate_users_information($users_information) { $users = array(); foreach ($users_information as $information) { if (!isset($users[$information->ID])) { $users[$information->ID] = new stdClass(); $users[$information->ID]->ID = $information->ID; $users[$information->ID]->user_login = $information->user_login; $users[$information->ID]->user_email = $information->user_email; $users[$information->ID]->user_url = $information->user_url; $users[$information->ID]->display_name = $information->display_name; $users[$information->ID]->value = $users[$information->ID]->display_name; $payment_terms = $this->payments->get_user_payment_terms($information->ID); $payment_terms_ids = array(); foreach ($payment_terms as $type => $terms) { foreach ($terms as $term) { $payment_terms_ids[] = "{$term->type}-{$term->id}"; } } $users[$information->ID]->payment_terms = $payment_terms_ids; } if ($information->meta_key == 'awpcp-profile') { $profile_info = maybe_unserialize($information->meta_value); $users[$information->ID]->address = awpcp_array_data('address', '', $profile_info); $users[$information->ID]->phone = awpcp_array_data('phone', '', $profile_info); $users[$information->ID]->country = awpcp_array_data('country', '', $profile_info); $users[$information->ID]->state = awpcp_array_data('state', '', $profile_info); $users[$information->ID]->city = awpcp_array_data('city', '', $profile_info); $users[$information->ID]->county = awpcp_array_data('county', '', $profile_info); } else { $users[$information->ID]->{$information->meta_key} = $information->meta_value; } } return $users; }
public function filter_conditions($conditions, $query) { foreach ($this->get_fields_in_query($query) as $field) { $value = awpcp_array_data($field->field_name, '', $query); $value = preg_replace('/\\*+$/', '', preg_replace('/^\\*+/', '', $value)); if (is_array($value) && (isset($value['min']) || isset($value['max']))) { $field_conditions = $this->create_conditions_for_range_field($field, $value, 'min', 'max', '`%1$s` >= %2$f', '`%1$s` <= %2$f'); $conditions = array_merge($conditions, $field_conditions); } else { if (is_array($value) && (isset($value['from_date']) || isset($value['to_date']))) { $field_conditions = $this->create_conditions_for_range_field($field, $value, 'from_date', 'to_date', '`%1$s` >= \'%2$s\'', '`%1$s` <= \'%2$s\''); $conditions = array_merge($conditions, $field_conditions); } else { if (is_array($value)) { $field_conditions = array(); foreach ($value as $key => $val) { $field_conditions[] = $this->db->prepare("`{$field->field_name}` LIKE '%%%s%%'", trim($val)); } if (!empty($field_conditions)) { $conditions[] = '(' . implode(' OR ', $field_conditions) . ' )'; } } else { if (strlen($value) > 0 && strlen($value) <= 4) { $conditions[] = $this->db->prepare("`{$field->field_name}` = '%s'", $value); } else { if ('' != $value) { // MATCH AGAINST requires fulltext indexes, we don't have that for // Extra Fields columns in Ads table. Switching to LIKE until // Extra Fields information is stored in a better place: a // *meta table for Ads. // // A phrase that is enclosed within double quote (“"”) // // characters matches only rows that contain the phrase // // literally, as it was typed. The full-text engine splits the // // phrase into words and performs a search in the FULLTEXT // // index for the words. Nonword characters need not be matched // // exactly: Phrase searching requires only that matches contain // // exactly the same words as the phrase and in the same order. // // For example, "test phrase" matches "test, phrase". // // If the phrase contains no words that are in the index, the // // result is empty. For example, if all words are either // // stopwords or shorter than the minimum length of indexed // // words, the result is empty. // $sql = ' AND MATCH (' . `{$field->field_name}` . ') AGAINST (\'"%s"\' IN BOOLEAN MODE) '; // Using LIKE since it does not requires index, although not having them // can cause performance issues if the table has too many rows (>10k) $conditions[] = $this->db->prepare("`{$field->field_name}` LIKE '%%%s%%'", $value); } } } } } } return $conditions; }
public function save($region) { global $wpdb; if (!isset($region['ad_id']) || empty($region['ad_id'])) { return false; } $region = stripslashes_deep($region); if (intval(awpcp_array_data('id', null, $region)) > 0) { $result = $wpdb->update(AWPCP_TABLE_AD_REGIONS, $region, array('id' => $region['id'])); } else { $result = $wpdb->insert(AWPCP_TABLE_AD_REGIONS, $region); } return $result !== false; }
public function save_contact_information($user_id) { if (!current_user_can('edit_user', $user_id)) { return; } $profile = (array) get_user_meta($user_id, 'awpcp-profile', true); $contact_information = $this->request->post('awpcp-profile'); $profile['phone'] = awpcp_array_data('phone', '', $contact_information); $profile['address'] = awpcp_array_data('address', '', $contact_information); $profile['email'] = $this->request->post('email'); $profile['website'] = $this->request->post('url'); $posted_regions = $this->request->post('regions', array()); $location = (array) array_shift($posted_regions); $profile['country'] = awpcp_array_data('country', '', $location); $profile['state'] = awpcp_array_data('state', '', $location); $profile['city'] = awpcp_array_data('city', '', $location); $profile['county'] = awpcp_array_data('county', '', $location); update_user_meta($user_id, 'awpcp-profile', $profile); do_action('awpcp-user-profile-updated', $profile, $user_id); }
public static function find_or_create($id) { $transaction = AWPCP_Payment_Transaction::find_by_id($id); if (is_null($transaction)) { $unique = awpcp_array_data('UNIQUE_ID', rand(), $_SERVER); $id = md5($unique . microtime() . wp_salt()); $transaction = new AWPCP_Payment_Transaction(array('id' => $id)); } return $transaction; }
/** * TODO: Perhaps the search should be improved to consider the type of * the field being searched for. */ function extra_fields_search_where($fields = array()) { global $wpdb; $data = awpcp_extra_fields()->get_posted_data(array(), 'search'); if (!is_array($fields) && !empty($fields)) { $fields = array($fields); } $keywordphrase = awpcp_array_data('keywordphrase', '', $data); if (empty($fields) && empty($keywordphrase)) { return ''; } $conditions_for_fields_with_empty_values = array(); if (!empty($keywordphrase)) { $sql = "( ad_title LIKE '%%%s%%' OR ad_details LIKE '%%%s%%' )"; $conditions_for_fields_with_empty_values[] = $wpdb->prepare($sql, $keywordphrase, $keywordphrase); } $where = ''; foreach ($fields as $field) { $value = awpcp_array_data($field->field_name, '', $data); $field_name = "`{$field->field_name}`"; $value = preg_replace('/\\*+$/', '', preg_replace('/^\\*+/', '', $value)); if (is_array($value) && (isset($value['min']) || isset($value['max']))) { $conditions = array(); if (strlen($value['min']) > 0) { $conditions[] = $wpdb->prepare("{$field_name} >= %f", $value['min']); } if (strlen($value['max']) > 0) { $conditions[] = $wpdb->prepare("{$field_name} <= %f", $value['max']); } if (!empty($conditions)) { $where .= ' AND (' . implode(' AND ', $conditions) . ') '; } } else { if (is_array($value)) { $sets = array(); foreach ($value as $key => $val) { $sets[] = $wpdb->prepare(" {$field_name} LIKE '%%%s%%' ", trim($val)); } $where .= ' AND (' . implode(' OR ', $sets) . ') '; } else { if ('' != $value) { if (strlen($value) <= 4) { $sql = " AND " . $field_name . " = '%s' "; } else { // MATCH AGAINST requires fulltext indexes, we don't have that for // Extra Fields columns in Ads table. Switching to LIKE until // Extra Fields information is stored in a better place: a // *meta table for Ads. // // A phrase that is enclosed within double quote (“"”) // // characters matches only rows that contain the phrase // // literally, as it was typed. The full-text engine splits the // // phrase into words and performs a search in the FULLTEXT // // index for the words. Nonword characters need not be matched // // exactly: Phrase searching requires only that matches contain // // exactly the same words as the phrase and in the same order. // // For example, "test phrase" matches "test, phrase". // // If the phrase contains no words that are in the index, the // // result is empty. For example, if all words are either // // stopwords or shorter than the minimum length of indexed // // words, the result is empty. // $sql = ' AND MATCH (' . $field_name . ') AGAINST (\'"%s"\' IN BOOLEAN MODE) '; // Using LIKE since it does not requires index, although not having them // can cause performance issues if the table has too many rows (>10k) $sql = " AND {$field_name} LIKE '%%%s%%' "; } $where .= $wpdb->prepare($sql, $value); } else { if ('' == $value && '' != $keywordphrase) { if (strlen($keywordphrase) <= 3) { $conditions_for_fields_with_empty_values[] = $wpdb->prepare(" {$field_name} = '%s' ", $keywordphrase); } else { $conditions_for_fields_with_empty_values[] = $wpdb->prepare(" {$field_name} LIKE '%%%s%%' ", $keywordphrase); } } } } } } if (count($conditions_for_fields_with_empty_values) > 0 && $where != '') { $where = sprintf(" AND ( ( %s ) %s )", implode(' OR ', $conditions_for_fields_with_empty_values), $where); } elseif (count($conditions_for_fields_with_empty_values) > 0 && $where == '') { $where = sprintf(" AND ( %s )", implode(' OR ', $conditions_for_fields_with_empty_values)); } return $where; }
public function add_image($ad, $media) { $action = awpcp_post_param('awpcp_action', false); $errors = array(); if ($action !== 'add_image' || is_null($ad)) { return $this->show_images($ad); } if ($_FILES['awpcp_add_file']['error'] !== 0) { $message = awpcp_uploaded_file_error($_FILES['awpcp_add_file']); awpcp_flash(end($message), 'error'); } else { if (wp_verify_nonce($_POST['_wpnonce'], 'awpcp_upload_image')) { $files = array('awpcp_add_file' => $_FILES['awpcp_add_file']); $uploaded = awpcp_upload_files($ad, $files, $errors); if (empty($uploaded)) { $message = _x('There was an error trying to upload your file.', 'media manager', 'AWPCP'); awpcp_flash(awpcp_array_data('awpcp_add_file', $message, $errors), 'error'); } else { $admin_must_approve = get_awpcp_option('imagesapprove'); $is_admin_user = awpcp_current_user_is_admin(); if (!$is_admin_user && $admin_must_approve) { awpcp_ad_awaiting_approval_email($ad, false, true); } awpcp_flash(_x('The file was properly uploaded.', 'media manager', 'AWPCP')); } } } return $this->show_images($ad); }
?> <?php echo awpcp_form_error('category', $form_errors); ?> </p> <?php if (awpcp_current_user_is_moderator()) { ?> <h3><?php echo esc_html(_x('Please select the owner for this Ad', 'place ad order step', 'AWPCP')); ?> </h3> <p class="awpcp-form-spacer"> <?php echo awpcp_users_field()->render(array('required' => true, 'selected' => awpcp_array_data('user', '', $form), 'label' => __('User', 'AWPCP'), 'default' => __('Select an User owner for this Ad', 'AWPCP'), 'id' => 'ad-user-id', 'name' => 'user', 'class' => array('awpcp-users-dropdown', 'awpcp-dropdown'))); ?> <?php echo awpcp_form_error('user', $form_errors); ?> </p> <?php } ?> <?php if (!$skip_payment_term_selection) { ?> <?php echo $payments->render_payment_terms_form_field($transaction, $table, $form_errors); ?>
public function get_views() { $filters = array('new' => 'new', 'expired' => 'expired', 'awaiting-approval' => 'awaiting-approval', 'images-awaiting-approval' => 'images-awaiting-approval', 'is-featured' => 'featured-ads', 'flagged' => 'flagged-ads', 'unpaid' => 'unpaid-ads', 'non-verified' => 'non-verified-ads', 'completed' => 'completed'); $selected = awpcp_array_data($this->params['filterby'], 'completed', $filters); $views = array('new' => array(__('New', 'AWPCP'), $this->page->url(array('filterby' => 'new', 'filter' => true))), 'expired' => array(__('Expired', 'AWPCP'), $this->page->url(array('filterby' => 'expired', 'filter' => true))), 'awaiting-approval' => array(__('Ads Awaiting Approval', 'AWPCP'), $this->page->url(array('filterby' => 'awaiting-approval', 'filter' => true))), 'images-awaiting-approval' => array(__('Images Awaiting Approval', 'AWPCP'), $this->page->url(array('filterby' => 'images-awaiting-approval', 'filter' => true))), 'featured-ads' => array(__('Featured', 'AWPCP'), $this->page->url(array('filterby' => 'is-featured', 'filter' => true))), 'flagged-ads' => array(__('Flagged', 'AWPCP'), $this->page->url(array('filterby' => 'flagged', 'filter' => true))), 'unpaid-ads' => array(__('Unpaid', 'AWPCP'), $this->page->url(array('filterby' => 'unpaid', 'filter' => true))), 'non-verified-ads' => array(__('Unverified', 'AWPCP'), $this->page->url(array('filterby' => 'non-verified', 'filter' => true))), 'completed' => array(__('Completed', 'AWPCP'), $this->page->url(array('filterby' => 'completed', 'filter' => false)))); return $this->page->links($views, $selected); }
/** * @since 3.4 */ function awpcp_send_listing_media_uploaded_notifications($file, $listing) { if (!$file->is_awaiting_approval()) { return false; } $referer = parse_url($_SERVER['HTTP_REFERER']); $referer_vars = wp_parse_args(awpcp_array_data('query', '', $referer)); if (!isset($referer_vars['page']) || !in_array($referer_vars['page'], array('awpcp-listings', 'awpcp-panel'))) { return false; } if (!isset($referer_vars['action']) || $referer_vars['action'] != 'manage-images') { return false; } $subject = __('There are images awaiting approval in listing <listing-title>', 'AWPCP'); $subject = str_replace('<listing-title>', $listing->get_title(), $subject); $message = __('The file <<file-name>> was added to listing "<listing-title>" and is awaiting administrator approval.', 'AWPCP'); $message = str_replace('<file-name>', $file->name, $message); $message = str_replace('<listing-title>', $listing->get_title(), $message); $mail = new AWPCP_Email(); $mail->to = array(awpcp_admin_email_to()); $mail->subject = $subject; $template = AWPCP_DIR . '/templates/email/listing-media-awaiting-approval.plain.tpl.php'; $mail->prepare($template, compact('listing', 'file', 'message')); return $mail->send(); }
/** * @param array $data Normalized array with Ad details. All fields are expected * to be present: isset($data['param']) === true * @param array $errors * @return boolean true if data validates, false otherwise */ protected function validate_details($data = array(), $edit = false, $payment_term = null, &$errors = array()) { global $hasextrafieldsmodule; // $edit = !empty($data['ad_id']); $is_moderator = awpcp_current_user_is_moderator(); $user_id = awpcp_array_data('user_id', 0, $data); $user_payment_term = awpcp_array_data('user_payment_term', '', $data); if (get_awpcp_option('freepay') == 1 && $user_id > 0 && empty($user_payment_term) && !$edit) { $errors['user_payment_term'] = __('You did not select a Payment Term. Please select a Payment Term for this Ad.', 'AWPCP'); } $start_date = strtotime($data['start_date']); if ($edit && $is_moderator && empty($data['start_date'])) { $errors['start_date'] = __('Please enter a start date for the Ad.', 'AWPCP'); } $end_date = strtotime($data['end_date']); if ($edit && $is_moderator && empty($data['end_date'])) { $errors['end_date'] = __('Please enter an end date for the Ad.', 'AWPCP'); } if ($edit && $is_moderator && $start_date > $end_date) { $errors['start_date'] = __('The start date must occur before the end date.', 'AWPCP'); } // Check for ad title if (empty($data['ad_title'])) { $errors['ad_title'] = __("You did not enter a title for your Ad", "AWPCP"); } // Check for ad details if (empty($data['ad_details'])) { $errors['ad_details'] = __("You did not enter any text for your Ad. Please enter some text for your Ad.", "AWPCP"); } // Check for ad category if (empty($data['ad_category']) && $edit) { $errors['ad_category'] = __("You did not select a category for your Ad. Please select a category for your Ad.", "AWPCP"); } // If website field is checked and required make sure website value was entered if (get_awpcp_option('displaywebsitefield') == 1 && get_awpcp_option('displaywebsitefieldreqop') == 1) { if (empty($data['websiteurl'])) { $errors['websiteurl'] = __("You did not enter your website address. Your website address is required.", "AWPCP"); } } //If they have submitted a website address make sure it is correctly formatted if (!empty($data['websiteurl']) && !isValidURL($data['websiteurl'])) { $errors['websiteurl'] = __("Your website address is not properly formatted. Please make sure you have included the http:// part of your website address", "AWPCP"); } // Check for ad poster's name if (empty($data['ad_contact_name'])) { $errors['ad_contact_name'] = __("You did not enter your name. Your name is required.", "AWPCP"); } // Check for ad poster's email address if (empty($data['ad_contact_email'])) { $errors['ad_contact_email'] = __("You did not enter your email. Your email is required.", "AWPCP"); } // Check if email address entered is in a valid email address format if (!awpcp_is_valid_email_address($data['ad_contact_email'])) { $errors['ad_contact_email'] = __("The email address you entered was not a valid email address. Please check for errors and try again.", "AWPCP"); } else { if (!awpcp_is_email_address_allowed($data['ad_contact_email'])) { $message = __('The email address you entered is not allowed in this website. Please use an email address from one of the following domains: %s.', 'AWPCP'); $domains_whitelist = explode("\n", get_awpcp_option('ad-poster-email-address-whitelist')); $domains_list = '<strong>' . implode('</strong>, <strong>', $domains_whitelist) . '</strong>'; $errors['ad_contact_email'] = sprintf($message, $domains_list); } } // If phone field is checked and required make sure phone value was entered if (get_awpcp_option('displayphonefield') == 1 && get_awpcp_option('displayphonefieldreqop') == 1) { if (empty($data['ad_contact_phone'])) { $errors['ad_contact_phone'] = __("You did not enter your phone number. Your phone number is required.", "AWPCP"); } } $region_fields = array(); foreach ($data['regions'] as $region) { foreach ($region as $type => $value) { if (!empty($value)) { $region_fields[$type] = true; } } } // If country field is checked and required make sure country value was entered if ($payment_term->regions > 0 && get_awpcp_option('displaycountryfield') == 1 && get_awpcp_option('displaycountryfieldreqop') == 1) { if (!awpcp_array_data('country', false, $region_fields)) { $errors['regions'] = __("You did not enter your country. Your country is required.", "AWPCP"); } } // If state field is checked and required make sure state value was entered if ($payment_term->regions > 0 && get_awpcp_option('displaystatefield') == 1 && get_awpcp_option('displaystatefieldreqop') == 1) { if (!awpcp_array_data('state', false, $region_fields)) { $errors['regions'] = __("You did not enter your state. Your state is required.", "AWPCP"); } } // If city field is checked and required make sure city value was entered if ($payment_term->regions > 0 && get_awpcp_option('displaycityfield') == 1 && get_awpcp_option('displaycityfieldreqop') == 1) { if (!awpcp_array_data('city', false, $region_fields)) { $errors['regions'] = __("You did not enter your city. Your city is required.", "AWPCP"); } } // If county/village field is checked and required make sure county/village value was entered if ($payment_term->regions > 0 && get_awpcp_option('displaycountyvillagefield') == 1 && get_awpcp_option('displaycountyvillagefieldreqop') == 1) { if (!awpcp_array_data('county', false, $region_fields)) { $errors['regions'] = __("You did not enter your county/village. Your county/village is required.", "AWPCP"); } } // If price field is checked and required make sure a price has been entered if (get_awpcp_option('displaypricefield') == 1 && get_awpcp_option('displaypricefieldreqop') == 1) { if (strlen($data['ad_item_price']) === 0 || $data['ad_item_price'] === false) { $errors['ad_item_price'] = __("You did not enter the price of your item. The item price is required.", "AWPCP"); } } // Make sure the item price is a numerical value if (get_awpcp_option('displaypricefield') == 1 && strlen($data['ad_item_price']) > 0) { if (!is_numeric($data['ad_item_price'])) { $errors['ad_item_price'] = __("You have entered an invalid item price. Make sure your price contains numbers only. Please do not include currency symbols.", "AWPCP"); } } if ($hasextrafieldsmodule == 1) { // backward compatibility with old extra fields if (function_exists('validate_extra_fields_form')) { $_errors = validate_extra_fields_form($data['ad_category']); } else { if (function_exists('validate_x_form')) { $_errors = validate_x_form(); } } if (isset($_errors) && !empty($_errors)) { $errors = array_merge($errors, (array) $_errors); } } // Terms of service required and accepted? if (!$edit && !$is_moderator && get_awpcp_option('requiredtos') && empty($data['terms-of-service'])) { $errors['terms-of-service'] = __("You did not accept the terms of service", "AWPCP"); } if (!$edit && !is_admin() && get_awpcp_option('captcha-enabled')) { $captcha = awpcp_create_captcha(get_awpcp_option('captcha-provider')); $error = ''; if (!$captcha->validate($error)) { $errors['captcha'] = $error; } } if (get_awpcp_option('useakismet')) { $spam_filter = awpcp_listing_spam_filter(); if ($spam_filter->is_spam($data)) { $errors[] = __("Your Ad was flagged as spam. Please contact the administrator of this site.", "AWPCP"); } } return count(array_filter($errors)) === 0; }
public function render($context, $translations = array(), $errors = array()) { $fields = $this->get_region_fields($context); if (empty($fields)) { return ''; } wp_enqueue_script('awpcp-multiple-region-selector'); awpcp()->js->localize('multiple-region-selector', array('select-placeholder' => _x('Select %s', 'Select <Region Type> in Multiple Region Selector', 'AWPCP'), 'duplicated-region' => __('This particular region is already selected in another field. Please choose one or more sub-regions, to make the selection more specific, or change the selected region.', 'AWPCP'), 'add-region' => $context == "search" ? __('Add Search Region', 'AWPCP') : __('Add Region', 'AWPCP'), 'remove-region' => $context == "search" ? __('Delete Search Region', 'AWPCP') : __('Remove Region', 'AWPCP'))); $regions = array(); foreach ($this->regions as $i => $region) { $hierarchy = array(); foreach ($fields as $type => $field) { $selected = awpcp_array_data($type, null, $region); $regions[$i][$type] = $field; $regions[$i][$type]['options'] = $this->get_region_field_options($context, $type, $selected, $hierarchy); $regions[$i][$type]['selected'] = awpcp_array_data($type, null, $region); $regions[$i][$type]['required'] = 'search' == $context ? false : $field['required']; if (isset($translations[$type])) { $regions[$i][$type]['param'] = $translations[$type]; } else { $regions[$i][$type]['param'] = $type; } // make values selected in parent fields available to child // fields when computing the field options. $hierarchy[$type] = $regions[$i][$type]['selected']; } } // use first region as template for additional regions $this->options['template'] = $regions[0]; $options = apply_filters('awpcp-multiple-region-selector-configuration', $this->options, $context, $fields); $uuid = uniqid(); awpcp()->js->set("multiple-region-selector-{$uuid}", array('options' => array_merge($options, array('fields' => array_keys($fields), 'context' => $context)), 'regions' => $regions)); ob_start(); include $this->template; $html = ob_get_contents(); ob_end_clean(); return $html; }
public function render_checkout_page($transaction, $hidden = array()) { $payment_method = $this->get_transaction_payment_method($transaction); $attempts = awpcp_post_param('attempts', 0); $result = awpcp_array_data($transaction->id, array(), $this->cache); if (is_null($payment_method) || isset($result['errors'])) { $transaction_errors = awpcp_array_data('errors', array(), $result); ob_start(); include AWPCP_DIR . '/frontend/templates/payments-checkout-page.tpl.php'; $html = ob_get_contents(); ob_end_clean(); } else { if (isset($result['output'])) { $integration = $payment_method->get_integration_type(); if ($integration === AWPCP_PaymentGateway::INTEGRATION_BUTTON) { $message = _x('Please use the button below to complete your payment.', 'checkout-payment page', 'AWPCP'); $html = $this->render_checkout_payment_template($result['output'], $message, $transaction); } else { if ($integration === AWPCP_PaymentGateway::INTEGRATION_CUSTOM_FORM) { $html = $result['output']; } else { if ($integration === AWPCP_PaymentGateway::INTEGRATION_REDIRECT) { $html = $result['output']; } } } } } return $html; }
function awpcp_form_error($field, $errors) { $error = awpcp_array_data($field, '', $errors); return empty($error) ? '' : '<span class="awpcp-error">' . $error . '</span>'; }
function url_showad($ad_id) { try { $ad = awpcp_listings_collection()->get($ad_id); } catch (AWPCP_Exception $e) { return false; } $seoFriendlyUrls = get_awpcp_option('seofriendlyurls'); $permastruc = get_option('permalink_structure'); $awpcp_showad_pageid = awpcp_get_page_id_by_ref('show-ads-page-name'); $base_url = get_permalink($awpcp_showad_pageid); $url = false; $params = array('id' => $ad_id); if ($seoFriendlyUrls && isset($permastruc) && !empty($permastruc)) { $url = sprintf('%s/%s', trim($base_url, '/'), $ad_id); $region = $ad->get_first_region(); $parts = array(); if (get_awpcp_option('include-title-in-listing-url')) { $parts[] = sanitize_title($ad->get_title()); } if (get_awpcp_option('include-city-in-listing-url') && $region) { $parts[] = sanitize_title(awpcp_array_data('city', '', $region)); } if (get_awpcp_option('include-state-in-listing-url') && $region) { $parts[] = sanitize_title(awpcp_array_data('state', '', $region)); } if (get_awpcp_option('include-country-in-listing-url') && $region) { $parts[] = sanitize_title(awpcp_array_data('country', '', $region)); } if (get_awpcp_option('include-county-in-listing-url') && $region) { $parts[] = sanitize_title(awpcp_array_data('county', '', $region)); } if (get_awpcp_option('include-category-in-listing-url')) { $awpcp_ad_category_id = $ad->ad_category_id; $parts[] = sanitize_title(get_adcatname($awpcp_ad_category_id)); } // always append a slash (RSS module issue) $url = sprintf("%s%s", trailingslashit($url), join('/', array_filter($parts))); $url = user_trailingslashit($url); } else { $base_url = user_trailingslashit($base_url); $url = add_query_arg(urlencode_deep($params), $base_url); } return apply_filters('awpcp-listing-url', $url, $ad); }
public function all_in_one_seo_pack_title($title) { global $aioseop_options; $title_format = awpcp_array_data('aiosp_page_title_format', '', $aioseop_options); if (string_starts_with($title_format, '%page_title%')) { $seplocation = 'right'; } else { $seplocation = 'left'; } return $this->title_builder->build_title($title, '', $seplocation); }
private function get_page_title($fallback_separator = '-', $seplocation = 'right') { $separator = $this->get_separator($fallback_separator); $parts = array(); if (!empty($this->category_id)) { $parts[] = get_adcatname($this->category_id); } else { if (!is_null($this->listing)) { $regions = $this->listing->get_regions(); if (count($regions) > 0) { $region = $regions[0]; } else { $region = array(); } if (get_awpcp_option('showcategoryinpagetitle')) { $parts[] = get_adcatname($this->listing->ad_category_id); } if (get_awpcp_option('showcountryinpagetitle')) { $parts[] = awpcp_array_data('country', '', $region); } if (get_awpcp_option('showstateinpagetitle')) { $parts[] = awpcp_array_data('state', '', $region); } if (get_awpcp_option('showcityinpagetitle')) { $parts[] = awpcp_array_data('city', '', $region); } if (get_awpcp_option('showcountyvillageinpagetitle')) { $parts[] = awpcp_array_data('county', '', $region); } $parts[] = $this->listing->get_title(); } } $parts = array_filter($parts); $parts = $seplocation === 'right' ? array_reverse($parts) : $parts; return implode(" {$separator} ", $parts); }
function awpcp_getip() { if (awpcp_validip(awpcp_array_data("HTTP_CLIENT_IP", '', $_SERVER))) { return $_SERVER["HTTP_CLIENT_IP"]; } foreach (explode(",", awpcp_array_data("HTTP_X_FORWARDED_FOR", '', $_SERVER)) as $ip) { if (awpcp_validip(trim($ip))) { return $ip; } } if (awpcp_validip(awpcp_array_data("HTTP_X_FORWARDED", '', $_SERVER))) { return $_SERVER["HTTP_X_FORWARDED"]; } elseif (awpcp_validip(awpcp_array_data('HTTP_FORWARDED_FOR', '', $_SERVER))) { return $_SERVER["HTTP_FORWARDED_FOR"]; } elseif (awpcp_validip(awpcp_array_data("HTTP_FORWARDED", '', $_SERVER))) { return $_SERVER["HTTP_FORWARDED"]; } else { return awpcp_array_data("REMOTE_ADDR", '', $_SERVER); } }
/** * @since 3.0.2 * @deprecated 3.4 */ function awpcp_get_allowed_mime_types() { return awpcp_array_data('mime_types', array(), awpcp_get_upload_file_constraints()); }
/** * @param $header array of columns in the CSV file * @param $csv two dimensional array of data extracted from CSV file * @param $zip true if a ZIP file with images was included */ private function import_ads($header, $csv, $import_dir, &$errors, &$messages) { global $wpdb; $region_columns = array('city', 'state', 'country', 'county_village'); $test_import = $this->options['test-import']; $images_created = array(); foreach ($csv as $k => $data) { $row = $k + 1; $columns = array(); $values = array(); $placeholders = array(); $region = array(); $email = awpcp_array_data('contact_email', '', $data); $category = awpcp_array_data('category_name', '', $data); list($category_id, $category_parent_id) = $this->get_category_id($category); // if ($category == 0) { // $msg = __('Category name not found at row number %d', 'AWPCP'); // $msg = sprintf($msg, $row); // $this->rejected[$row] = true; // $errors[] = $msg; // break; // } foreach ($this->columns as $key => $column) { // DO NOT USE awpcp_array_data BECAUSE IT WILL TREAT '0' AS // AN EMPTY VALUE $value = isset($data[$key]) ? $data[$key] : ''; $_errors = array(); if ($key == 'username') { $value = awpcp_csv_importer_get_user_id($value, $email, $row, $_errors, $messages); } else { if ($key == 'category_name') { $value = $category_id; } else { if ($key == 'category_parent') { $value = $category_parent_id; } else { $value = $this->parse($value, $key, $row, $_errors); } } } if ($key == 'username' && empty($value) && !empty($_errors)) { $this->rejected[$row] = true; $errors = array_merge($errors, $_errors); break; } // if there was an error getting a value for this field, // but the field wasn't included in the CSV, skip and mark // the row as good if ($value === false && !in_array($key, $header)) { $this->rejected[$row] = false; continue; } array_splice($errors, count($errors), 0, $_errors); // missing value, mark row as bad if (strlen($value) === 0 && in_array($key, $this->required)) { $msg = __('Required value <em>%s</em> missing at row number: %d', 'AWPCP'); $msg = sprintf($msg, $key, $row); $this->rejected[$row] = true; $errors[] = $msg; break; } if (in_array($key, $region_columns)) { if ($key == 'county_village') { $region['county'] = $value; } else { $region[$key] = $value; } } else { $placeholders[] = empty($this->types[$key]) ? '%d' : '%s'; $values[] = $value; $columns[] = $column; } } foreach ($this->auto_columns as $key => $value) { if ($value == '?') { $value = $this->parse($value, $key, $row, $errors); } $columns[] = $key; $placeholders[] = empty($this->auto_columns_types[$key]) ? '%d' : '%s'; $values[] = empty($this->auto_columns_types[$key]) ? 0 : $value; } foreach ($this->extra_fields as $field) { $name = $field->field_name; // validate only extra fields present in the CSV file if (!isset($data[$name])) { continue; } $validate = $field->field_validation; $type = $field->field_input_type; $options = $field->field_options; $category = $field->field_category; $enforce = in_array($category_id, $category); $value = awpcp_validate_extra_field($name, $data[$name], $row, $validate, $type, $options, $enforce, $errors); // we found an error, let's skip this row if ($value === false) { $this->rejected[$row] = true; break; } switch ($field->field_mysql_data_type) { case 'VARCHAR': case 'TEXT': $placeholders[] = '%s'; break; case 'INT': $placeholders[] = '%d'; break; case 'FLOAT': $placeholders[] = '%f'; break; } $columns[] = $name; $values[] = $value; } if ($import_dir) { $image_names = explode(';', $data['images']); $images = $this->import_images($image_names, $row, $import_dir, $errors); $this->images_imported += count($images); // save created images to be deleted later, if test mode is on array_splice($images_created, 0, 0, $images); } else { $images = array(); } // if there was an error, skip this row and try to import the next one if (awpcp_array_data($row, false, $this->rejected)) { $this->ads_rejected++; continue; } $sql = 'INSERT INTO ' . AWPCP_TABLE_ADS . ' '; $sql .= '( ' . join(', ', $columns) . ' ) VALUES ( ' . join(', ', $placeholders) . ' ) '; $sql = $wpdb->prepare($sql, $values); if ($test_import) { $inserted_id = 5; } else { $wpdb->query($sql); $inserted_id = $wpdb->insert_id; } if (!empty($region)) { $this->save_regions($region, $inserted_id, $row, $errors); } if (!empty($images)) { $this->save_images($images, $inserted_id, $row, $errors); } $this->ads_imported++; } if ($import_dir) { $this->remove_images($import_dir, $images_created); } if ($this->ads_imported > 0 && !$test_import) { do_action('awpcp-listings-imported'); } }
<td> <input id="awpcp-profile-phone" class="regular-text" type="text" name="awpcp-profile[phone]" value="<?php echo esc_attr(awpcp_array_data('phone', '', $profile)); ?> " /> <span class="description"></span> </td> </tr> <tr valign="top"> <th scope="row"> <label for="awpcp-profile-address"><?php _e('Address', 'AWPCP'); ?> </label> </th> <td> <input id="awpcp-profile-address" class="regular-text" type="text" name="awpcp-profile[address]" value="<?php echo esc_attr(awpcp_array_data('address', '', $profile)); ?> " /> <span class="description"></span> </td> </tr> </tbody> </table> <?php $selector_options = array('showTextField' => true, 'maxRegions' => 1); $selected_region = array(array('country' => awpcp_array_data('country', '', $profile), 'state' => awpcp_array_data('state', '', $profile), 'city' => awpcp_array_data('city', '', $profile), 'county' => awpcp_array_data('county', '', $profile))); $selector = awpcp_multiple_region_selector_with_template($selected_region, $selector_options, 'form-table'); echo $selector->render('user-profile', array(), array());
public function ajax_import_payment_transactions() { global $wpdb; $existing_transactions = $this->count_old_payment_transactions(); $query = 'SELECT option_name FROM ' . $wpdb->options . ' '; $query .= "WHERE option_name LIKE 'awpcp-payment-transaction-%' "; $query .= "LIMIT 0, 100"; $transactions = $wpdb->get_col($query); foreach ($transactions as $option_name) { $hash = end(explode('-', $option_name)); $transaction_errors = array(); $transaction = AWPCP_Payment_Transaction::find_by_id($hash); if (is_null($transaction)) { $transaction = new AWPCP_Payment_Transaction(array('id' => $hash)); } $data = maybe_unserialize(get_option($option_name, null)); // can't process this transaction, skip and delete old data if (!is_array($data)) { delete_option($option_name); continue; } $errors = awpcp_array_data('__errors__', array(), $data); $user_id = awpcp_array_data('user-id', null, $data); $amount = awpcp_array_data('amount', 0.0, $data); $items = awpcp_array_data('__items__', array(), $data); $created = awpcp_array_data('__created__', current_time('mysql'), $data); $updated = awpcp_array_data('__updated__', current_time('mysql'), $data); if ($type = awpcp_array_data('payment-term-type', false, $data)) { if (strcmp($type, 'ad-term-fee') === 0) { $data['payment-term-type'] = 'fee'; } } foreach ($data as $name => $value) { $transaction->set($name, $value); } foreach ($items as $item) { $transaction->add_item($item->id, $item->name, '', AWPCP_Payment_Transaction::PAYMENT_TYPE_MONEY, $amount); // at the time of this upgrade, only one item was supported. break; } if (awpcp_array_data('free', false, $data)) { $transaction->payment_status = AWPCP_Payment_Transaction::PAYMENT_STATUS_NOT_REQUIRED; } $totals = $transaction->get_totals(); if ($totals['money'] === 0 || $transaction->get('payment-method', false) === '') { $transaction->payment_status = AWPCP_Payment_Transaction::PAYMENT_STATUS_NOT_REQUIRED; } if ($totals['money'] > 0 && $transaction->get('payment-method', false)) { $transaction->_set_status(AWPCP_Payment_Transaction::STATUS_PAYMENT); } if ($completed = awpcp_array_data('completed', null, $data)) { $transaction->completed = $completed; $transaction->payment_status = AWPCP_Payment_Transaction::PAYMENT_STATUS_COMPLETED; $transaction->_set_status(AWPCP_Payment_Transaction::STATUS_COMPLETED); } unset($data['__errors__']); unset($data['__items__']); unset($data['__created__']); unset($data['__updated__']); unset($data['user-id']); unset($data['completed']); unset($data['free']); $transaction->user_id = $user_id; $transaction->created = $created; $transaction->updated = $updated; $transaction->errors = $errors; $transaction->version = 1; // remove entries from wp_options table if ($transaction->save()) { delete_option($option_name); } } $remaining_transactions = $this->count_old_payment_transactions(); // we are done here, let the plugin know so othrer upgrades // can be initiated or the plugin features can be enabled again. if ($remaining_transactions === 0) { delete_option('awpcp-import-payment-transactions'); $this->update_pending_upgrades_status(); } return $this->ajax_response($existing_transactions, $remaining_transactions); }
public function get_file_types_in_group($group) { return awpcp_array_data($group, array(), $this->get_file_types()); }
/** * Handles AWPCPSHOWAD shortcode. * * @param $adid An Ad ID. * @param $omitmenu * @param $preview true if the function is used to show an ad just after * it was posted to the website. * @param $send_email if true and $preview=true, a success email will be send * to the admin and poster user. * * @return Show Ad page content. */ function showad($adid = null, $omitmenu = false, $preview = false, $send_email = true, $show_messages = true) { global $wpdb; awpcp_maybe_add_thickbox(); wp_enqueue_script('awpcp-page-show-ad'); $awpcp = awpcp(); $awpcp->js->set('page-show-ad-flag-ad-nonce', wp_create_nonce('flag_ad')); $awpcp->js->localize('page-show-ad', array('flag-confirmation-message' => __('Are you sure you want to flag this ad?', 'AWPCP'), 'flag-success-message' => __('This Ad has been flagged.', 'AWPCP'), 'flag-error-message' => __('An error occurred while trying to flag the Ad.', 'AWPCP'))); $preview = $preview === true || 'preview' == awpcp_array_data('adstatus', '', $_GET); $is_moderator = awpcp_current_user_is_moderator(); $messages = array(); $permastruc = get_option('permalink_structure'); if (!isset($adid) || empty($adid)) { if (isset($_REQUEST['adid']) && !empty($_REQUEST['adid'])) { $adid = $_REQUEST['adid']; } elseif (isset($_REQUEST['id']) && !empty($_REQUEST['id'])) { $adid = $_REQUEST['id']; } else { if (isset($permastruc) && !empty($permastruc)) { $adid = get_query_var('id'); } else { $adid = 0; } } } $adid = absint($adid); if (!empty($adid)) { // filters to provide alternative method of storing custom // layouts (e.g. can be outside of this plugin's directory) $prefix = 'awpcp_single_ad_template'; if (has_action("{$prefix}_action") || has_filter("{$prefix}_filter")) { do_action("{$prefix}_action"); return apply_filters("{$prefix}_filter"); } else { $results = AWPCP_Ad::query(array('where' => $wpdb->prepare('ad_id = %d', $adid))); if (count($results) === 1) { $ad = array_shift($results); } else { $ad = null; } if (is_null($ad)) { $message = __('Sorry, that listing is not available. Please try browsing or searching existing listings.', 'AWPCP'); return '<div id="classiwrapper">' . awpcp_print_error($message) . '</div><!--close classiwrapper-->'; } if ($ad->user_id > 0 && $ad->user_id == wp_get_current_user()->ID) { $is_ad_owner = true; } else { $is_ad_owner = false; } $content_before_page = apply_filters('awpcp-content-before-listing-page', ''); $content_after_page = apply_filters('awpcp-content-after-listing-page', ''); $output = '<div id="classiwrapper">%s%s<!--awpcp-single-ad-layout-->%s</div><!--close classiwrapper-->'; $output = sprintf($output, $content_before_page, $omitmenu ? '' : awpcp_menu_items(), $content_after_page); if (!$is_moderator && !$is_ad_owner && !$preview && $ad->disabled == 1) { $message = __('The Ad you are trying to view is pending approval. Once the Administrator approves it, it will be active and visible.', 'AWPCP'); return str_replace('<!--awpcp-single-ad-layout-->', awpcp_print_error($message), $output); } if (awpcp_request_param('verified') && $ad->verified) { $messages[] = awpcp_print_message(__('Your email address was successfully verified.', 'AWPCP')); } if ($show_messages && $is_moderator && $ad->disabled == 1) { $message = __('This Ad is currently disabled until the Administrator approves it. Only you (the Administrator) and the author can see it.', 'AWPCP'); $messages[] = awpcp_print_error($message); } else { if ($show_messages && ($is_ad_owner || $preview) && !$ad->verified) { $message = __('This Ad is currently disabled until you verify the email address used for the contact information. Only you (the author) can see it.', 'AWPCP'); $messages[] = awpcp_print_error($message); } else { if ($show_messages && ($is_ad_owner || $preview) && $ad->disabled == 1) { $message = __('This Ad is currently disabled until the Administrator approves it. Only you (the author) can see it.', 'AWPCP'); $messages[] = awpcp_print_error($message); } } } $layout = awpcp_get_listing_single_view_layout($ad); $layout = awpcp_do_placeholders($ad, $layout, 'single'); $output = str_replace('<!--awpcp-single-ad-layout-->', join('', $messages) . $layout, $output); $output = apply_filters('awpcp-show-ad', $output, $adid); if (!awpcp_request()->is_bot()) { $ad->visit(); } $ad->save(); } } else { $query = array('limit' => absint(awpcp_request_param('results', get_awpcp_option('adresultsperpage', 10))), 'offset' => absint(awpcp_request_param('offset', 0)), 'orderby' => get_awpcp_option('groupbrowseadsby')); $output = awpcp_display_listings_in_page($query, 'show-listing'); } return $output; }
<input class="textfield required" id="awpcp-billing-postal-code" type="text" size="50" name="postal_code" value="<?php echo esc_attr(awpcp_array_data('postal_code', '', $data)); ?> " data-bind="value: postal_code"> <?php echo awpcp_form_error('postal_code', $errors); ?> </div> <div class="awpcp-form-spacer clearfix"> <label for="awpcp-billing-email"><?php _e('Email', 'AWPCP'); ?> </label> <input class="textfield required" id="awpcp-billing-email" type="text" size="50" name="email" value="<?php echo esc_attr(awpcp_array_data('email', '', $data)); ?> " data-bind="value: email"> <?php echo awpcp_form_error('email', $errors); ?> </div> </fieldset> <p class="form-submit"> <?php foreach ($hidden as $name => $value) { ?> <input type="hidden" value="<?php echo esc_attr($value); ?>
/** * @since 3.0 */ function awpcp_do_placeholder_price($ad, $placeholder) { $price = empty($ad->ad_item_price) ? 0 : $ad->ad_item_price / 100; $show_price_field = get_awpcp_option('displaypricefield') == 1; $user_can_see_price_field = is_user_logged_in() || get_awpcp_option('price-field-is-restricted') == 0; if (get_awpcp_option('hide-price-field-if-empty') && $price <= 0) { $show_price_field = false; } $replacements = array(); if ($show_price_field && $user_can_see_price_field && $price >= 0) { $escaped_label = esc_html(__('Price', 'AWPCP')); $escaped_currency = esc_html(awpcp_format_money($price)); // single ad $content = '<div class="showawpcpadpage"><label>%s</label>: <strong>%s</strong></div>'; $replacements['aditemprice'] = sprintf($content, $escaped_label, $escaped_currency); // listings $replacements['awpcp_display_price'] = sprintf('%s: %s', $escaped_label, $escaped_currency); $replacements['price'] = $escaped_currency; } return awpcp_array_data($placeholder, '', $replacements); }
?> <h3><?php echo esc_html(__('Add Details and Contact Information', 'AWPCP')); ?> </h3> <?php if ($ui['category-field']) { ?> <p class="awpcp-form-spacer"> <?php $dropdown = new AWPCP_CategoriesDropdown(); ?> <?php echo $dropdown->render(array('selected' => awpcp_array_data('ad_category', '', $form), 'name' => 'ad_category')); ?> <?php echo awpcp_form_error('ad_category', $errors); ?> </p> <?php } ?> <?php echo awpcp_form_fields()->render_fields($form, $errors, isset($listing) ? $listing : null, array('category' => $form['ad_category'], 'action' => 'normal')); ?> <?php if ($ui['terms-of-service']) {
:</label> <input type="text" id="query" class="inputbox" size="50" name="keywordphrase" value="<?php echo esc_attr($form['query']); ?> " /> <?php echo awpcp_form_error('query', $errors); ?> </p> <p class="awpcp-form-spacer"> <?php $dropdown = new AWPCP_CategoriesDropdown(); ?> <?php echo $dropdown->render(array('context' => 'search', 'selected' => awpcp_array_data('category', '', $form), 'name' => 'searchcategory', 'required' => false)); ?> </p> <?php if ($ui['posted-by-field']) { ?> <p class='awpcp-form-spacer'> <label for="name"><?php _e("For Ads Posted By", "AWPCP"); ?> </label> <select id="name" name="searchname"> <option value=""><?php _e("All Users", "AWPCP"); ?>